+ Reply to Thread
Results 1 to 3 of 3

Run-time error 1004 error on Mac only Application.Get.Save.AsFilename

Hybrid View

  1. #1
    Registered User
    Join Date
    10-03-2016
    Location
    Santa Barbara, CA
    MS-Off Ver
    2010
    Posts
    2

    Run-time error 1004 error on Mac only Application.Get.Save.AsFilename

    Good morning,

    I'm a first time poster--these boards have been a lifesaver for me over the years. This one has me stumped.

    I have a password-protected VBA-enabled workbook that's used by a variety of Mac and PC users. Has worked like a charm for years.

    Lately a couple of Mac users have complained of an error: run-time error 1004 'MethodSaveAsFilename' of object '_Application' failed when then they try to save the file to their computers. I've encountered no issues with PC users

    The code follows: debugger highlights five rows after do statement, again only on Macs--no problem on PCs.

    Many thanks in advance.

            If SaveAs Or Len(Me.Path) = 0 Then
                If Val(Application.Version) < 12 Then
                    FileFilter = "Microsoft Office Excel Workbook (*.xls), *.xls"
                    FilterIndex = 1
                Else
                    FileFilter = "Excel Macro-Enabled Workbook (*.xlsm), *.xlsm, " & _
                        "Excel 97-2003 Workbook (*.xls), *.xls"
                    If Right(Me.Name, 4) = ".xls" Then
                        FilterIndex = 2
                    Else
                        FilterIndex = 1
                    End If
                End If
                Do
                    FileName = Application.GetSaveAsFilename( _
                        InitialFileName:=Me.Name, _
                        FileFilter:=FileFilter, _
                        FilterIndex:=FilterIndex, _
                        Title:="SaveAs")
                    If FileName = "False" Then Exit Do
                    If IsLegalFilename(FileName) = False Then
                        Msg = "The file name is invalid.  Try one of the "
                        Msg = Msg & "following:" & vbCrLf & vbCrLf
                        Msg = Msg & Chr(149) & " Make sure that the file name "
                        Msg = Msg & "does not contain any" & vbCrLf
                        Msg = Msg & "   of the following characters:  "
                        Msg = Msg & "< > ? [ ] : | or *" & vbCrLf
                        Msg = Msg & Chr(149) & " Make sure that the file/path "
                        Msg = Msg & "name does not exceed" & vbCrLf
                        Msg = Msg & "   more than 218 characters."
                        MsgBox Msg, vbExclamation, "Invalid File Name"
                    Else
                        If Val(Application.Version) < 12 Then
                            FileFormat = -4143
                        Else
                            If Right(FileName, 4) = ".xls" Then
                                FileFormat = 56
                            Else
                                FileFormat = 52
                            End If
                        End If
                        If Len(Dir(FileName)) = 0 Then
                            Application.DisplayAlerts = False
                            Me.SaveAs FileName, FileFormat
                            Application.DisplayAlerts = True
                            WorkbookSaved = True
                        Else
                            Ans = MsgBox("'" & FileName & "' already exists.  " & _
                                "Do you want to replace it?", vbQuestion + vbYesNo, _
                                "Confirm Save As")
                            If Ans = vbYes Then
                                Application.DisplayAlerts = False
                                Me.SaveAs FileName, FileFormat
                                Application.DisplayAlerts = True
                                WorkbookSaved = True
                            End If
                        End If
                    End If
                Loop Until Me.Saved
            Else
                Application.DisplayAlerts = False
                Me.Save
                Application.DisplayAlerts = True
                WorkbookSaved = True
            End If

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: Run-time error 1004 error on Mac only Application.Get.Save.AsFilename

    There are a few nice parameters that you can use with GetSaveAsFileName that all work OK in Windows but not on a Mac. Filefilter is a very important one that is not working on a Mac.

    Ron de Bruin has a work-around.
    GetSaveAsFileName on a Mac
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    10-03-2016
    Location
    Santa Barbara, CA
    MS-Off Ver
    2010
    Posts
    2

    Re: Run-time error 1004 error on Mac only Application.Get.Save.AsFilename

    Thank you so much for the helpful referral!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Error message: Run-Time error '1004 '; application-defined or object-defined error
    By Davasu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2015, 06:52 AM
  2. Replies: 1
    Last Post: 10-22-2015, 05:50 AM
  3. VBA ERROR: run time error 1004: Application-defined or Object-defined error in excel 2013
    By AnanthKrishna in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2015, 06:16 AM
  4. [SOLVED] Sort Macro Run-time error '1004': Application/Object-defined error.
    By sam1212 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-22-2014, 10:05 AM
  5. [SOLVED] Error " Run-time error '1004': application defined or object defined error
    By lengwer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2013, 07:26 AM
  6. [SOLVED] run-time error '1004': Application-defined or object-deifined error
    By rich5665@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-10-2005, 05:05 PM
  7. [SOLVED] Application Run Time Error 1004 and Stack Error
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-11-2005, 01:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1