RE: saving a file using file dialog in Access 2007

Tech-Archive recommends: Fix windows errors by optimizing your registry



If the api call you referenced is not working for you, then you are not using
it correctly. I have been using it for years with no problems. It has been
so long since I used the file dialog, I don't remember if it is possible
using that object, but I do know that with the api, you can pass a default
file name and that will show as the file name to save.

Here is an example where I do this:

'Set up default path and file
strCurrYear = Me.txtCurrYear
strCurrMonth = Me.cboPeriod.Column(1)
'Set up default path and file
strDefaultDir = "\\rsltx1-bm01\busmgmt\Vought " & strCurrYear & "\" &
strCurrYear _
& " Actuals\" & strCurrMonth & "\FFP Charts\"
strDefaultFileName = Me.cboOffering & " Summary " &
Me.cboPeriod.Column(1) _
& " " & Me.txtCurrYear & ".xls"
'Set filter to show only Excel spreadsheets
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)")
'Flags Hides the Read Only Check and Only allow existing files
lngFlags = ahtOFN_HIDEREADONLY Or ahtOFN_OVERWRITEPROMPT
'Call the Open File Dialog
varGetFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
InitialDir:=strDefaultDir, _
Filter:=strFilter, _
Filename:=strDefaultFileName, _
Flags:=lngFlags, _
DialogTitle:="Save Report")
If varGetFileName <> "" Then
xlBook.SaveAs Filename:=varGetFileName
End If

--
Dave Hargis, Microsoft Access MVP


"Brian" wrote:

I am trying to use FileDialog in combination with TransferSpread*** to save
a file named by the user in a directory of the user's choice. I am able to
bring up the SaveAs dialog box with no problem but the user has to select a
file in order to save the current file as that file.

In my program, the user pulls data specific to a month and year and a table
is created that has in its name the month and year that has just been
entered. Therefore, I would like to avoid having the user retype in the
information and just pass the filename string to save the file using the
dialog box. I have tried using the api0001.htm but quite frankly cannot get
it to work. Regardless, I can get the dialog box to work in either the open
file or save file mode but I need to know if there is a way to save a file
with a string using FileDialog.

I am not a sophisticated programmer, in fact even using "programmer" is a
stretch. :-) Any help will be much appreciated. Thanks,
--
Brian
.


Quantcast