469,641 Members | 1,134 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,641 developers. It's quick & easy.

Changing from Common Dialogs Control to API Calls

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
1 2874
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.

Similar topics

5 posts views Thread by John Lauwers | last post: by
1 post views Thread by SpotNet | last post: by
4 posts views Thread by Adam | last post: by
6 posts views Thread by Steve Barnett | last post: by
2 posts views Thread by MLM450 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.