ExcelNewbie29
New Member
- Joined
- Jan 5, 2023
- Messages
- 3
- Office Version
- 365
- Platform
- Windows
I am at a loss for how to fix this issue I am having. I am sure it is something simple, but I think I have stared at it too long to understand what mistake I am making. As the name indicates, I am new to VBA and learning in order to make my life and my coworkers lives easier.
Context: We have a report that we have to produce ~40 of each month. Each one is slightly different than the others, as they are presented in various groups and meetings. I have 2 working macros and 1 that does not work - the export to PDF macro. I am looking to click a button (shape designed and macro assigned already) and that will automatically export the active sheet to PDF and name it (Cell B5) (Cell I3) FDAF Deck. It is ok for it to go to the default folder, since I am unable to save it to a shared drive due to company security settings. The goal is that this should allow myself/coworkers to create the presentation sheet that is needed and have it saved based on the meeting group they are presenting to and the month/year.
Here is the code. Again, new to VBA so feel free laugh at the very rudimentary code.
Sub Export_To_PDF()
'Create and Assign Variables
Dim saveLocation As String
saveLocation = "Range(B5).Value & Range(I3).Value & FDAF Deck"
'ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=saveLocation, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
From:=1, _
To:=5, _
OpenAfterPublish:=True
End Sub
I am unsure why this will not work for me. I a nearly identical code written into the previous version of this file, but I created a secondary version to change some of the formatting and such without losing the first one. The other codes seem to work just fine, so it is only Export to PDF that is causing me heartburn. Any/all assistance is appreciated!
Context: We have a report that we have to produce ~40 of each month. Each one is slightly different than the others, as they are presented in various groups and meetings. I have 2 working macros and 1 that does not work - the export to PDF macro. I am looking to click a button (shape designed and macro assigned already) and that will automatically export the active sheet to PDF and name it (Cell B5) (Cell I3) FDAF Deck. It is ok for it to go to the default folder, since I am unable to save it to a shared drive due to company security settings. The goal is that this should allow myself/coworkers to create the presentation sheet that is needed and have it saved based on the meeting group they are presenting to and the month/year.
Here is the code. Again, new to VBA so feel free laugh at the very rudimentary code.
Sub Export_To_PDF()
'Create and Assign Variables
Dim saveLocation As String
saveLocation = "Range(B5).Value & Range(I3).Value & FDAF Deck"
'ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=saveLocation, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
From:=1, _
To:=5, _
OpenAfterPublish:=True
End Sub
I am unsure why this will not work for me. I a nearly identical code written into the previous version of this file, but I created a secondary version to change some of the formatting and such without losing the first one. The other codes seem to work just fine, so it is only Export to PDF that is causing me heartburn. Any/all assistance is appreciated!