User selection to save a report (1 Viewer)

Sam Summers

Registered User.
Local time
Today, 22:42
Joined
Sep 17, 2001
Messages
892
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
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 05:42
Joined
May 7, 2009
Messages
16,129
on VBA->Tools->Reference

Add reference to Microsoft Office XX.X Object library (where XX.X is the version number of your mso).
 

Sam Summers

Registered User.
Local time
Today, 22:42
Joined
Sep 17, 2001
Messages
892
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?
 

Sam Summers

Registered User.
Local time
Today, 22:42
Joined
Sep 17, 2001
Messages
892
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?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 05:42
Joined
May 7, 2009
Messages
16,129
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
 

Sam Summers

Registered User.
Local time
Today, 22:42
Joined
Sep 17, 2001
Messages
892
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

Top Bottom