Frankietheflyer
New Member
- Joined
- Nov 17, 2017
- Messages
- 30
Hi
My code checks to see if a folder exists and creates one if it doesn't before going on to produced a dynamic number of PDF documents and save them in the folder.
The Code works, but I decided to try and be clever and give the user the opportunity of opening the folder once all the PDFs had been produced by having a Yes / No message box.
All goes well until I click on "Yes" when the code fails and tells me the folder cannot be found. However, the folder IS there!
The created folder is called "FolderName" and hovering over that word in DeBug clearly shows the path and folder name in inverted comers ("C:\Users" & Environ("USERNAME") & ("\Documents\PDF Team Sheets for Meeting ").
Any ideas why the code can't find the folder please??
The relevant bit of code at the end of making the PDFs is as follows:
Thanks
Frankie
My code checks to see if a folder exists and creates one if it doesn't before going on to produced a dynamic number of PDF documents and save them in the folder.
The Code works, but I decided to try and be clever and give the user the opportunity of opening the folder once all the PDFs had been produced by having a Yes / No message box.
All goes well until I click on "Yes" when the code fails and tells me the folder cannot be found. However, the folder IS there!
The created folder is called "FolderName" and hovering over that word in DeBug clearly shows the path and folder name in inverted comers ("C:\Users" & Environ("USERNAME") & ("\Documents\PDF Team Sheets for Meeting ").
Any ideas why the code can't find the folder please??
The relevant bit of code at the end of making the PDFs is as follows:
Code:
[FONT=Verdana][FONT=Verdana]OpenFolder = MsgBox("The PDF Team Sheets have been produced and are in the Documents folder" & Chr(13) & Chr(13) & "PDF Team Sheets for Meeting " & ThisWorkbook.Sheets("Race Meeting Information").Range("B3").Value & Chr(13) & Chr(13) & "Do you want to open the folder?", vbYesNo)[/FONT]
If OpenFolder = vbYes Then[/FONT]
[FONT=Verdana]
Call Shell("explorer.exe" & FolderName, vbNormalFocus)[/FONT]
[FONT=Verdana]Application.ScreenUpdating = True
Exit Sub[/FONT]
[FONT=Verdana]
Else[/FONT]
[FONT=Verdana]
Application.ScreenUpdating = True[/FONT]
[FONT=Verdana]End If[/FONT]
[FONT=Verdana]End Sub[/FONT]
Thanks
Frankie
Last edited: