DoCmd OutputTo Method (1 Viewer)

sailinxtc

Registered User.
Local time
Today, 07:15
Joined
Apr 27, 2008
Messages
34
utilizing the DoCmd OutputTo Method and leaving the OpenFile blank so it prompts for the file name, is there a way you can set the filename and still have it open the output to dialog where the user can choose the path but the filename is already set in the dialog ?

Code:
Dim pdfFile As String
pdfFile = (Screen.ActiveForm.name)
DoCmd.OutputTo acOutputReport, pdfFile, acFormatPDF, , False
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 13:15
Joined
Sep 12, 2006
Messages
15,710
when you pick a file with a filepicker, all it returns is a string

you can easily strip off the filename, and replace it with one of your own.

alternatively, just look for a folder picker.
 

sailinxtc

Registered User.
Local time
Today, 07:15
Joined
Apr 27, 2008
Messages
34
using the code I posted, I am not sure I am picking a file, I don't give a output file so it prompts me for a file name, can I utilize what I am using already with the DoCmd outputto or are you stateing I need to do something differnt and use a folder picker ? I am not that familiar, do you have a reference, thanks...
 

DavidAtWork

Registered User.
Local time
Today, 13:15
Joined
Oct 25, 2011
Messages
699
As GTH says the best way is probably to use the Folder Picker method and then add the filename;
ie
Dim outputPath as String
outputPath= dialogFolderBrowse
outputPath = outputPath & "\myFile.pdf
then
DoCmd.OutputTo acOutputReport, pdfFile, acFormatPDF, outputPath, False

David
 

DavidAtWork

Registered User.
Local time
Today, 13:15
Joined
Oct 25, 2011
Messages
699
here's the dialogueFolderBrowse function code:
Function dialogFolderBrowse() As String
'##### This function gives the user the facility to browse for a folder and to be able to use the path
'##### as a destination.
'##### You must set a refrence the Microsoft Office 11.0 Object Library, go to Tools/References
Dim fp As FileDialog
Dim vrtSelectedItem As Variant
Dim varX As String

'Create a FileDialog object as a Folder Picker dialog box.


Set fp = Application.FileDialog(msoFileDialogFolderPicker) ' can use msoFileDialogFilePicker for filenames
fp.AllowMultiSelect = True
If fp.Show = -1 Then
'this is the only way I've been able to assign the selected path as a value to string variable
For Each vrtSelectedItem In fp.SelectedItems
varX = vrtSelectedItem
Next vrtSelectedItem
End If

dialogFolderBrowse = varX

End Function
 

Users who are viewing this thread

Top Bottom