Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Excel > Excel Programming

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 07-12-2018, 01:48 PM
darbykate darbykate is offline Windows 10 Office 2016
Novice
 
Join Date: Jul 2018
Posts: 3
darbykate is on a distinguished road
Default problem with excel to pdf macro

Good Afternoon!
I'm having some issues with a macro that I built to select certain sheets of my excel file to export as a PDF. It's saving with the correct name and in the correct place, but the sheets only show the footer and maybe one line.

Below is what i have.
Sub Print_To_PDF()
' Print_to_PDF Macro

' Set Path to Save
fPath = "C:\Users\dkdougl1\Documents\"
'Set File Name
fName = Sheets("Notes and Warnings").Range("A33")

'Select sheets to Print to PDF
Sheets(Array("Calibration Sheet", "Weighing Dry", "Weighing Wet", "Final Weigh", "Base Mix Sheet", "Final Mix Sheet", "Weigh Up Operations", "Base Start Up Operations", "Base Mixing Operations", _
"Base Mill Operations", "Final Start Up", "Final Mix Operations", _
"Final Mill Operations")).Select



'Print Selected Sheets to PDF
Selection.ExportAsFixedFormat Type:=x1TypePDF, FileName:=fPath & fName, OpenAfterPublish:=True

End Sub


Thanks!
Reply With Quote
  #2  
Old 07-12-2018, 04:35 PM
NoSparks NoSparks is offline Windows 7 64bit Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 618
NoSparks will become famous soon enoughNoSparks will become famous soon enough
Default

Have you tried
Code:
'Print Selected Sheets to PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=fPath & fName, _
     IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
Reply With Quote
  #3  
Old 07-13-2018, 12:10 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Windows 7 64bit Office 2010 64bit
Moderator
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,146
Pecoflyer is just really nicePecoflyer is just really nicePecoflyer is just really nicePecoflyer is just really nicePecoflyer is just really nice
Default

You might also find some help at http://www.rondebruin.nl/win/section1.htm
__________________
Problem solved ? Let others know by clicking " Thread Tools" then " Mark thread as solved".( This can be undone if need be)
Reply With Quote
  #4  
Old 07-13-2018, 05:35 AM
darbykate darbykate is offline Windows 10 Office 2016
Novice
 
Join Date: Jul 2018
Posts: 3
darbykate is on a distinguished road
Default

Quote:
Originally Posted by NoSparks View Post
Have you tried
Code:
'Print Selected Sheets to PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=fPath & fName, _
     IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
Wouldn't that only export the one sheet I'm on?
Reply With Quote
  #5  
Old 07-13-2018, 05:37 AM
darbykate darbykate is offline Windows 10 Office 2016
Novice
 
Join Date: Jul 2018
Posts: 3
darbykate is on a distinguished road
Default

Quote:
Originally Posted by darbykate View Post
Wouldn't that only export the one sheet I'm on?
I should've tried it before I posted. That worked, thank you!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Macro: Multiple Search and Post in Excel Sheet andxie Excel Programming 10 05-31-2018 05:21 PM
Excel Macro Problem billbowers Excel 3 04-27-2015 01:19 AM
How To Open an Macro From 2003 Excel in 2013 Excel Spread Sheet? ADubin Excel Programming 3 02-08-2015 04:57 AM
EXCEL macro problem please help! ryguy551 Excel Programming 2 05-22-2014 03:58 PM
Problem with macro MS baby Excel Programming 4 03-31-2014 02:47 PM


All times are GMT -7. The time now is 02:08 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft