Modified code create subfolder and save as pdf to it based on cell
Solved/Closed
abdelfatah_0230
Posts
73
Registration date
Thursday July 18, 2019
Status
Member
Last seen
July 23, 2022
-
Sep 20, 2020 at 07:04 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Sep 29, 2020 at 11:16 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Sep 29, 2020 at 11:16 AM
Related:
- Activesheet.exportasfixedformat type:=xltypepdf,
- Save as pdf office 2007 - Download - Other
- Battery reset code - Guide
- How to save google doc with comments as pdf - Guide
- Create skype account with gmail - Guide
- Samsung volume increase code - Guide
1 response
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Updated on Sep 22, 2020 at 12:02 PM
Updated on Sep 22, 2020 at 12:02 PM
Hi Abdel,
Here you go:
NOTE: I did assume you don't have the ".pdf" extention added to your filename in cell I2. If you do, then remove the "& ".pdf" part on code line 13.
Best regards,
Trowa
Here you go:
Sub RunMe() Dim mPath, mPathFile As String Dim oW As Long mPath = "C:\Users\OSE\Downloads\client\" & ActiveSheet.Range("H2").Value & "\" mPathFile = mPath & ActiveSheet.Range("I2").Value If Dir(mPath, vbDirectory) = vbNullString Then MkDir mPath GoTo sFile End If If CBool(Len(Dir$(mPathFile & ".pdf")) > 0) = True Then oW = MsgBox("Overwrite existing file?", vbQuestion + vbYesNo, "File Exists") If oW = vbYes Then GoTo sFile Else Exit Sub End If Else GoTo sFile End If Exit Sub sFile: ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=mPathFile _ , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _ :=False, OpenAfterPublish:=False End Sub
NOTE: I did assume you don't have the ".pdf" extention added to your filename in cell I2. If you do, then remove the "& ".pdf" part on code line 13.
Best regards,
Trowa
Updated on Sep 26, 2020 at 09:54 AM
thanks again
Sep 28, 2020 at 11:52 AM
Good to hear!
To prevent the missing data error, paste the piece of code between code line 3 and 5:
Best regards,
Trowa
Sep 28, 2020 at 03:39 PM
best regards,
abdelfattah
Sep 29, 2020 at 11:16 AM