You should still be able to save it to a desktop folder.
I wouldn’t have thought that a different case letter would stop it from being able to save to that folder.
So definitely try Gasman’s recommendation to debug.print or msgbox the fldrPath variable might help you identify the issue with the path.
You could also try changing the particular letter to uppercase.
If it’s the first letter try:
Code:
strusername = StrConv(strusername,3)
Before building your path variable.
Just a thought.
Sent from my iPhone using Tapatalk[/QUOTE
Not sure why though, that is what I see as well when I debug print, I see the flder path, and that's how I figured out the lower case upper case difference, environ user name function uses upper case and the folder name is lower case...anyway i tried saving it somewhere else and it works, but the users complain that it takes about 2 to 3 minutes to complete for some reason so I just created it as an attachment... thank you very much!
Hello everyone, hope you are all doing fine. I hope I can get some help on this code I found by googling. This always says I have Invalid folder path. I don't know which I causing the error. Here's the code:
Dim fileName As String, fldrPath As String, filePath As String, strusername As String
Dim answer As Integer:banghead:
strusername = Environ("UserName")
fileName = "Template-Please Rename" 'filename for PDF file*
fldrPath = "C:\documents and settings" & strusername & "\Desktop" 'folder path where pdf file will be saved *
filePath = fldrPath & "" & fileName & ".pdf"
'check if file already exists
If FileExist(filePath) Then
answer = MsgBox(prompt:="PDF file already exists: " & vbNewLine & filePath & vbNewLine & vbNewLine & _
"Would you like to replace existing file?", buttons:=vbYesNo, Title:="Existing PDF File")
If answer = vbNo Then Exit Sub
End If
On Error GoTo invalidFolderPath
DoCmd.OutputTo objecttype:=acOutputReport, objectName:=Me.Name, outputformat:=acFormatPDF, outputFile:=filePath
MsgBox prompt:="PDF File exported to: " & vbNewLine & filePath, buttons:=vbInformation, Title:="Report Exported as PDF"
Exit Sub
fldrPath = "C:\documents and settings" & strusername & "\Desktop" 'folder path where pdf file will be saved *
filePath = fldrPath & "" & fileName & ".pdf"
CORRECT THE ABOVE LINES AS
fldrPath = "C:\documents and settings\" & strusername & "\Desktop\" 'folder path where pdf file will be saved *
filePath = fldrPath & fileName & ".pdf"
fldrPath = "C:\documents and settings" & strusername & "\Desktop" 'folder path where pdf file will be saved *
filePath = fldrPath & "" & fileName & ".pdf"
CORRECT THE ABOVE LINES AS
fldrPath = "C:\documents and settings\" & strusername & "\Desktop\" 'folder path where pdf file will be saved *
filePath = fldrPath & fileName & ".pdf"