Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2002
    Posts
    5

    Unanswered: msoFileDialogSaveAs does not work "Object doesn't support this action"

    I'm using the standard MS File Dialogs and have come accross a problem when trying to bring up a dialog box to allow users to specify a new file to mailmerge to.
    According to Microsoft they haven't coded the SaveAs dialog into Access XP (Great ) as I've just discovered here:
    http://support.microsoft.com/default...b;EN-US;282335

    Anyway what I'd like to know is does anyone have any suggestions to do the following another way?

    Set dlgSaveAs = Application.FileDialog(msoFileDialogOpen)
    With dlgSaveAs
    .Title = "Create New MailMerge"
    .Filters.Add "Word Document", "*.doc", 1
    .Filters.Add "Word Template", "*.dot", 2
    .FilterIndex = 1
    .AllowMultiSelect = False
    .InitialFileName = strSaveDir
    .InitialView = msoFileDialogViewList
    FileSelected = (.Show = -1)
    End With
    If FileSelected Then
    strNewName = dlgSaveAs.SelectedItems.Item(1)
    Else
    Exit Function
    End If

  2. #2
    Join Date
    Dec 2003
    Location
    Toronto, Ont. Canada
    Posts
    238

    Re: msoFileDialogSaveAs does not work "Object doesn't support this action"

    I know I've done this before... but do you think I can find my example??... Nope...

    You can use an API to do this...
    Check out the link below...
    http://www.mvps.org/access/api/api0001.htm

    I was playing with some sample code I had and came up with this example... It's doesn't save anything... but will bring up the dialogs and give you an idea... Run the OpenSaveAsDialog procedure and you'll see what I mean...
    Code:
    Private Const OFN_EXPLORER = &H80000
    Private Type OPENFILENAME
        lStructSize As Long
        hwndOwner As Long
        hInstance As Long
        lpstrFilter As String
        lpstrCustomFilter As String
        nMaxCustFilter As Long
        nFilterIndex As Long
        lpstrFile As String
        nMaxFile As Long
        lpstrFileTitle As String
        nMaxFileTitle As Long
        lpstrInitialDir As String
        lpstrTitle As String
        flags As Long
        nFileOffset As Integer
        nFileExtension As Integer
        lpstrDefExt As String
        lCustData As Long
        lpfnHook As Long
        lpTemplateName As String
    End Type
    Private Declare Function GetOpenFileNamePreview Lib "msvfw32.dll" (ByRef lpofn As OPENFILENAME) As Long
    Private Declare Function GetSaveFileNamePreview Lib "msvfw32.dll" Alias "GetSaveFileNamePreviewA" (ByRef lpofn As OPENFILENAME) As Long
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    
    Private Sub OpenSaveAsDialog()
        Dim OFN As OPENFILENAME, Ret As Long
        With OFN
            .lStructSize = Len(OFN)
            .lpstrTitle = "Open a file"
            .lpstrFilter = "Word Document (*.doc)" + Chr$(0) + "*.doc" + Chr$(0) + _
                            "Word Template (*.dot)" + Chr$(0) + "*.dot" + Chr$(0) + _
                            "All files (*.*)" + Chr$(0) + "*.*"
            .lpstrFile = String(255, 0)
            .nMaxFile = 255
            .flags = OFN_EXPLORER
        End With
        Ret = GetOpenFileNamePreview(OFN)
        If Ret <> 0 Then
            CloseHandle Ret
            MsgBox "The file you chose was " + Left$(OFN.lpstrFile, InStr(1, OFN.lpstrFile, Chr$(0)) - 1)
        End If
        OFN.lpstrTitle = "Save a file"
        Ret = GetSaveFileNamePreview(OFN)
        If Ret <> 0 Then
            GetSaveFileName (OFN)
            CloseHandle Ret
            MsgBox "The file you chose was " + Left$(OFN.lpstrFile, InStr(1, OFN.lpstrFile, Chr$(0)) - 1)
        End If
    End Sub
    Good luck!
    HTH

Posting Permissions

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