+ Reply to Thread
Results 1 to 3 of 3

Error with Save As PDF macro in Mac but not in Windows

  1. #1
    Registered User
    Join Date
    01-06-2016
    Location
    Boston, MA
    MS-Off Ver
    2010
    Posts
    2

    Question Error with Save As PDF macro in Mac but not in Windows

    The primary user of the file is on a mac running Excel 2011 and he gets a runtime error
    run-time error 1004: method ExportAsFixedFormat of object worksheet failed.

    I'm not sure why it's not working on the Mac as it works on Windows. Hoping someone can help. Thanks so much!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Error with Save As PDF macro in Mac but not in Windows

    Hi gazellette and welcome to ExcelForum,

    Thank you for using 'Code Tags'.

    Please Login or Register  to view this content.
    I do not use a MAC, but my speculation is that the item in red may be the cause of your problems, because the path separator in Windows is '\' and the path separator in MAC is ':'. I suggest you start with something like the sample Macro above. Start with fName as a file Name only like 'abc.pdf' and start building from there.

    After that is successful, try using GetSaveAsFilename(), and see if it fails, see what the difference is between the hard coded file name and the file name you got using GetSaveAsFilename().

    The following Windows debugging tips probably work on the MAC too:
    a. Press 'F8' to single step (goes into subroutines and functions).
    b. Press SHIFT 'F8' to single step OVER subroutines and functions.
    c. Press CTRL 'F8' to stop at the line where the cursor is.
    d. 'Left Click' the margin to the left of a line to set (or clear) a BREAKPOINT.
    e. Press CTRL 'G' to open the IMMEDIATE WINDOW. 'debug.print' statements send their
    output to the IMMEDIATE WINDOW.
    f. Select View > Locals to see all variables while debugging.
    g. To automatically set a BREAKPOINT at a certain location put in the line:
    'Debug.Assert False'
    h. To conditionally set a BREAKPOINT at a certain location put in lines similar to:
    if i >= 20 and xTV20 > 99.56 then
    Debug.Assert False
    endif
    i. A variable value will be displayed by putting the cursor over the variable name.

    To manually set a breakpoint, see http://www.wiseowl.co.uk/blog/s196/breakpoints.htm

    I hope this helps.

    Lewis

  3. #3
    Registered User
    Join Date
    01-06-2016
    Location
    Boston, MA
    MS-Off Ver
    2010
    Posts
    2

    Re: Error with Save As PDF macro in Mac but not in Windows

    Hi all -

    Just wanted to share the very roundabout solution we came up with for this - it only works with El Capital and Office for Mac 2016 so we had to update the user. GetSaveASFileName does not appear to work well on the Mac platform and often fails so we had to come up with a different way of asking the user for a file name and location.
    Thank you Lewis for the suggestion to start from a file name and build from there and the debugging tips!!

    Please Login or Register  to view this content.

+ 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. Excel add ons or macro error newer version of windows
    By Bluehat07 in forum Excel General
    Replies: 3
    Last Post: 11-24-2015, 07:10 AM
  2. [SOLVED] How do I save windows resizing and other settings in Windows Explorer?
    By Jacc in forum Microsoft Windows Help
    Replies: 2
    Last Post: 02-13-2015, 10:56 AM
  3. Save to PDF VBA error when file is transferred from XP to windows 7
    By S_Intern123 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-10-2014, 04:51 AM
  4. VBA code Error after changed to windows 7, working fine in windows XP before
    By Faridwahidi in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-11-2014, 06:23 AM
  5. Replies: 4
    Last Post: 06-20-2013, 09:30 AM
  6. [SOLVED] Windows 7 Autofill error in macro
    By bk77 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-20-2012, 03:53 PM
  7. Macro works fine on Windows XP, but it gives error on Vista or 7
    By maxxian in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-19-2012, 05:43 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