By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,500 Members | 830 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,500 IT Pros & Developers. It's quick & easy.

Changing from Common Dialogs Control to API Calls

P: n/a
To avoid having potential conflicts and problems with different
versions of Common Dialogs Controls, I have decided to change the ones
I have used to API calls; however, this is somewhat new territory for
me and would appreciate some assistance.

One that I had been using is shown below and has worked fine. I have
remarked most of the lines and added the Me!Test line and the Windows
Dialog box appeared, but obviously, I'm not referencing a field, but
rather a report. So what should precede the GetOpenFile?

Also, I would rather not lose the prior feature of having a default
string filter placing .HTML as the default in the Save as Type box. I
assume that I will have to tweak the API Function to do this. Any
suggestions? Also, if this be the case, then one could have several
large modules to service separate API calls - that seems rather
inefficient.

Guess the same would also apply to 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. Dalan
Private Sub cmdOutput_Click()

Me!Test = 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
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Code for using the Windows Common Dialog API directly, contributed by Ken
Getz, can be downloaded from http://www.mvps.org/access/api/api0001.htm and
it includes example code on how to use it.

Larry Linson
Microsoft Access MVP
"Dalan" <ot***@safe-mail.net> wrote in message
news:50**************************@posting.google.c om...
To avoid having potential conflicts and problems with different
versions of Common Dialogs Controls, I have decided to change the ones
I have used to API calls; however, this is somewhat new territory for
me and would appreciate some assistance.

One that I had been using is shown below and has worked fine. I have
remarked most of the lines and added the Me!Test line and the Windows
Dialog box appeared, but obviously, I'm not referencing a field, but
rather a report. So what should precede the GetOpenFile?

Also, I would rather not lose the prior feature of having a default
string filter placing .HTML as the default in the Save as Type box. I
assume that I will have to tweak the API Function to do this. Any
suggestions? Also, if this be the case, then one could have several
large modules to service separate API calls - that seems rather
inefficient.

Guess the same would also apply to 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. Dalan
Private Sub cmdOutput_Click()

Me!Test = 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

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.