Solved User selection to save a report (1 Viewer)

Sam Summers

Registered User.
Local time
Today, 14:49
Joined
Sep 17, 2001
Messages
939
Hi guys,

I have taken this code from a previous post of mine but it fails on the second line - Dim fd As FileDialog and comes up with the error message "user defined type not defined". Thought i had this but its got me with my limited abilities.
Thank you in advance

Code:
Dim MyFileName As String
Dim fd As FileDialog
Dim strFolder As String

 Me.JobNo.SetFocus
 MyFileName = ("SIE-RA-00" & strFileNo & "-21" & " Main Section") & ".pdf"
 
 Set fd = Application.FileDialog(msoFileDialogFolderPicker)

 If fd.Show = -1 Then
     strFolder = fd.SelectedItems.Item(1)
 Else
     Exit Sub
 End If

 DoCmd.OutputTo acOutputReport, "MainBody", acFormatPDF, strFolder & MyFileName, False

 Set fd = Nothing
 
on VBA->Tools->Reference

Add reference to Microsoft Office XX.X Object library (where XX.X is the version number of your mso).
 
on VBA->Tools->Reference

Add reference to Microsoft Office XX.X Object library (where XX.X is the version number of your mso).
Good morning, i did that which brings up the file window but when i save the file in a location it isnt there?
 
Good morning, i did that which brings up the file window but when i save the file in a location it isnt there?
Right i found it and it saved itself as - DesktopSIE-RA-001-21 Main Section.pdf

I selected to save it to my Desktop and it saved it to my folder and added 'Desktop' to the front of the file name?
 
Code:
 If fd.Show = -1 Then
     strFolder = Replace$(fd.SelectedItems.Item(1) & "\", "\\", "\")
 Else
     Exit Sub
 End If
 
 
 DoCmd.OutputTo acOutputReport, "MainBody", acFormatPDF, strFolder & MyFileName, False

 Set fd = Nothing
End Sub
 
Code:
 If fd.Show = -1 Then
     strFolder = Replace$(fd.SelectedItems.Item(1) & "\", "\\", "\")
Else
     Exit Sub
End If


DoCmd.OutputTo acOutputReport, "MainBody", acFormatPDF, strFolder & MyFileName, False

Set fd = Nothing
End Sub
Well its working but it is saving it in the last folder i opened instead of the desktop or location i choose? Strange?
 

Users who are viewing this thread

Back
Top Bottom