I seem to be having an issue with a some VBA code that I wrote. It will create a PDF of the selected worksheet, naming it based on some predefined criteria. It creates the PDF just fine. The problem is that if I choose a folder to save it to, it saves
it to one folder up from that. So if I choose C:\My Documents\My Stuff it will save it to C:\My Documents. Any thoughts?
Here's the code for the Folder Picker sections:
Function GetSaveToFolder() As String
' Delcare a variable as a FileDialog Object
Dim fd As fileDialog
Dim newFolder As String
GetSaveToFolder = ""
' Create a FileDialog object as a File Picker Dialog box
Set fd = Application.fileDialog(msoFileDialogFolderPicker)
' Use a With...End With block to reference the FileDialog object.
With fd
' Use the show method to display the file picker dialog box and return the user's action.
' The user pressed the action button.
If .Show = -1 Then
GetSaveToFolder = .SelectedItems(1)
' at this time, the path does not have a "" at the end of it
' rather than just adding one on to it, we test to see if it is there
' and if not, then add it
' This keeps it working if they ever change the way
' the folder picker works
If Right(GetSaveToFolder, 1) <> Application.PathSeparator Then
GetSaveToFolder = GetSaveToFolder & Application.PathSeparator
End If
Else
' the user pressed cancel
End If
End With
' set the object variable to Nothing
Set fd = Nothing
End Function
Harlan