|
Perhaps a couple of tips regarding API calls using a function module
and I will be on my way to retiring the bug prone Common Dialogs
Controls.
One Common Dialog that I have been using is shown below and has worked
fine. I'm have been using it to copy a few queries in HTML format to
disk. So the main point is how to properly referenced an OutputTo
action when using an API function call. So what should precede the
GetOpenFile?
Of course, I would rather not lose the current features of having a
default string filter placing .HTML as the default in the Save as Type
box, and having a default path specified in the Save In box which is a
very beneficial feature of the current Dialog Control.
Thanks for your time and assistance.
Private Sub cmdOutput_Click()
Me!OutputTo? = GetOpenFile_CLT("C:\", "Save the Output")
' Dim oCmnDlg As CommonDialog
Dim strFormat As String
Dim strFileName As String
Dim stDocName As String
' Set oCmnDlg = Me!cmndlg.Object
On Error GoTo Export_Err
' With oCmnDlg
'.FileName = ""
'.Flags = cdlOFNOverwritePrompt + cdlOFNHideReadOnly
'.CancelError = True
'.Filter = "HTML Format (*.html)|*.html"
'.FilterIndex = 1
'.InitDir = "C:\Program Files\Database\Reports\"
'.ShowSave
'Select Case .FilterIndex
'Case 1
'strFormat = acFormatHTML
'End Select
'strFileName = .FileName
'End With
stDocName = "HTML Output"
DoCmd.OutputTo acOutputQuery, "ReportData", strFormat,
strFileName, False, "C:\Program
Files\Database\Template\ReportDataTemplate.html"
Exit Sub
Export_Exit:
Exit Sub
Export_Err:
If Err.Number = 32755 Or 2501 Then
Resume Export_Exit
Else
MsgBox Err.Number & ", " & Err.Description
End If
Resume Export_Exit
End Sub |