Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011

    Unanswered: Common Dialog blues

    Hi,

    I'm using the "Microsoft Common Dialog Control 6.0" in several different places in my Access 97 application.

    For some users, some forms will popup and say "you don't have a liscense to use this control" while other forms, in the same instance of the application on the same PC for the same user, work just fine.

    This problems seems to come and go, and the PCs on which it happens have the full install of Access 97 Prof (along with the full version of Office 97 Prof).

    I checked the references each time to confirm it's using "comdlg32.ocx"

    It has happend in Citrix, in Novell, under Windows 98, 2000 and XP and right here on my home computer, so OS and Environment don't seem to make a difference.

    Why, and more importantly, how do I fix it?

  2. #2
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    bump

  3. #3
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    I have used several forms of the CommonDialogBox and all of the OCX implementations are shakey, at best.

    I have found that the following code consistently reliable:

    Code:
    Option Compare Database
    Option Explicit
    
    Type adh_accOfficeGetFileNameInfo
    hwndOwner As Long
    strAppName As String * 255
    strWindowCaption As String * 255
    strButtonCaption As String * 255
    strFileName As String * 4096
    strInitialDirectory As String * 255
    strFileFilter As String * 255
    lngFilterIndex As Long
    lngView As Long
    lngFlags As Long
    End Type
    
    Declare Function adh_accOfficeGetFileName Lib "msaccess.exe" Alias "#56" (gfni As adh_accOfficeGetFileNameInfo, ByVal fopen As Integer) As Long
    
    Function CommonDialog(Optional Flags As Long = 0, Optional FileFilter As String = "", Optional FileName As String = "", Optional WindowCaption As String = "", Optional ButtonCaption As String = "", Optional InitialDirectory As String = "", Optional OpenOrSave As Boolean = True) As Variant
    
    
        Dim gfni As adh_accOfficeGetFileNameInfo
        
        gfni.lngFlags = Flags '0=File, 32=Directory
        gfni.strWindowCaption = WindowCaption & vbNullChar
        gfni.strButtonCaption = ButtonCaption & vbNullChar
        gfni.strFileName = FileName & vbNullChar
        gfni.strInitialDirectory = InitialDirectory & vbNullChar
        gfni.strFileFilter = FileFilter & vbNullChar
    
        If OpenOrSave = True Then
            If adh_accOfficeGetFileName(gfni, True) = 0 Then
                CommonDialog = Trim(IIf(InStr(gfni.strFileName, vbNullChar) = 0, gfni.strFileName, Left$(gfni.strFileName, InStr(gfni.strFileName, vbNullChar) - 1)))
            End If
        Else
            If adh_accOfficeGetFileName(gfni, False) = 0 Then
                CommonDialog = Trim(IIf(InStr(gfni.strFileName, vbNullChar) = 0, gfni.strFileName, Left$(gfni.strFileName, InStr(gfni.strFileName, vbNullChar) - 1)))
            End If
        End If
    
    End Function
    Ken

    Maverick Software Design

    (847) 864-3600 x2

  4. #4
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    Ken,

    Thank you very much!

    May I ask a followup: do you have a function that utilizes the Print Menu in a similar fashion?

    Unfortunately, for users running MDE, or those using "Run-Time", the "Print Options" dialog is not available - it prints directly to the default printer.

    I have noticed that the Print menu in the Common Dialog does 1 of 2 things: it's either useless (because it doesn't change the local printer settings) OR it's dangerous, becasue it changes the global printer settings.

    So, I've been using code that digs into the bowels of windows to get printer information to populate my own Print Panel. The catch is that I have to set the printer settings of my objects in design mode - which is not allowed in MDE.

    Thanks!!!

  5. #5
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    Concerning the Print Dialog,

    if you go to the customize toolbar functionality and select the shortcut toolbar, you can move the Print drag and drop the Print menubar item from the Reports>>Print Preview menubar and drop it into a menubar associated with previewing your reports. That menubar item will no longer be available in the right-click of the report print preview shortcut menu (it can apparently only be used in a single menubar).

    Now, that gets you the print dialog for "immediate" printing. You cannot, however, save those settings to the report object, in an .mde.

    In my projects, when I want to distribute an mde which will allow the user to select and save printer settings to a report, I distribute the mde as a secured mdb (named as an mde) and then have a routine which will invisibly open a report object in design view, provide the user with a print dialog and the save those settings to the report object. This is especially useful when the user's default printer might be a CAD plotter, but he/she wants my 8 1/2 x 11 report to print to another printer, without having to select that printer every time.

    Just some ideas.
    Ken

    Maverick Software Design

    (847) 864-3600 x2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •