Solved User selection to save a report (1 Viewer)

Sam Summers

Registered User.
Local time
Today, 20:11
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
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:11
Joined
May 7, 2009
Messages
19,169
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, 20:11
Joined
Sep 17, 2001
Messages
939
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, 20:11
Joined
Sep 17, 2001
Messages
939
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, 04:11
Joined
May 7, 2009
Messages
19,169
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, 20:11
Joined
Sep 17, 2001
Messages
939
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