vba save as pdf to specific folder with 3 cells value file name

denimfact

New Member
Joined
Oct 10, 2016
Messages
2
Hellow every one, i'm new in vba and my english is not so good. i have the following code to save as pdf with 1 cell value as file name.
I want to save as pdf with 3 cells value as file name. this code is best for my need if could edited for save as 3 cells value B5, D5 and E5 as file name.



Sub RoundedRectangle1_Click()


On Error Resume Next
MkDir "C:\MYRECIPE\"

Sheet3.Range("A1:F49").ExportAsFixedFormat xlTypePDF, _
Filename:="C:\MYRECIPE\" & Sheet1.Range("E5").Value, openafterpublish:=True

Sheet1.Range("E5") = Sheet1.Range("E5").Value + 1


End Sub
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Maybe
VBA Code:
Sub RoundedRectangle1_Click()
Dim strFile As String

On Error Resume Next
MkDir "C:\MYRECIPE\"
strFile = Sheet1.Range("B5") & Sheet1.Range("D5") & Sheet1.Range("E5")

Sheet3.Range("A1:F49").ExportAsFixedFormat xlTypePDF, _
Filename:="C:\MYRECIPE\" & strFileName,openafterpublish:=True

Sheet1.Range("E5") = Sheet1.Range("E5")+ 1

End Sub
Not sure why you'd have Resume Next as an error handler. If Dir fails you don't want to attempt the export or modify sheet 1? If the export fails, sheet 1 will still be modified.
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,625
Members
449,093
Latest member
catterz66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top