Macro does not work in other computers

Home Forums Astral Meta Forum Community Information Technology and Data Entry Macro does not work in other computers

Tagged: ,

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of jokr jokr 4 months, 3 weeks ago.

Topic Rating:
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #1606
    Profile photo of AL2Meta
    Points: 272

    I think I know what the problem is… although it would have been better if you show us your code, that way it would help us better analyze what the problem is..

    Anyway, since you got a “Method ‘SaveAs’ of object ‘_Workbook’ failed” error report, I’m pretty sure you use Excel to record a task that does something and save it for you. That process is what created your macro Visual Basic Script. Since you record it on your computer, it should be using your PC’s file path. Let’s say your computer’s user is MrExcel, then your file path should be “C:\Users\MrExcel\..”.

    Now, I’m assuming the other computer that runs your computer has a different user.. say Andrew so it has a “C:\Users\Andrew\..”. This is what gives you the error. Your Macro is trying to save your worksheet in a file path that is non existent in the other computer. The solution to this is to change the filepath.

    Look at this code in your debug console.. example below:

    ActiveWorkbook.SaveAs Filename:=”C:\Users\MrExcel\Desktop\sample.xlsx” _
    , FileFormat:=xlText, CreateBackup:=False

    In the above filepath, MrExcel is the user.. you should change MrExcel into the username of the computer that’s running the Macro or better yet, don’t specify a filepath.

    Change it to something like this: (with only the filename cited)

    ActiveWorkbook.SaveAs Filename:=”sample.xlsx” _
    , FileFormat:=xlText, CreateBackup:=False

    It should make your Macro run on any computer regardless of who the user is.

    Profile photo of jokr
    Points: 5

    It worked! Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. You may login using: