+ Reply to Thread
Results 1 to 2 of 2

How to make this Macro work for any user so they can save to their desktop

  1. #1
    Registered User
    Join Date
    01-24-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    How to make this Macro work for any user so they can save to their desktop

    I have created the following Macro: taking a worksheet from a workbook and saving it to desktop as "Customer Copy" excel file and then saving the "Customer Copy" excle file as a PDF file also on desktop, then closing both files.
    This works fine on my PC, the trouble I have is when I give this main workbook to others and they try to run the file they get an error Message, the usual End or Debug. My Macro is:

    Sub Macro1()
    '
    ' Macro1 Macro
    '

    '
    Sheets("Output Summary").Select
    Sheets("Output Summary").Copy
    ChDir "C:\Users\hardeep.sidhu\Desktop"
    ActiveWorkbook.SaveAs Filename:= _
    "C:\Users\hardeep.sidhu\Desktop\Customercopy.xlsx", FileFormat:= _
    xlOpenXMLWorkbook, CreateBackup:=False
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "C:\Users\hardeep.sidhu\Desktop\Customercopy.pdf", Quality:=xlQualityStandard _
    , IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
    False
    ActiveWindow.Close
    End Sub

    The error on a colleagues screens is on line:
    ChDir "C:\Users\hardeep.sidhu\Desktop"

    I need to replace my name Hardeep Sidhu with anyone using running the macro (i.e active user on their PC)

    Please can someone help fix the above code. I don't really understand any of this language.

    Kind Regards

    Hardeep

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,760

    Re: How to make this Macro work for any user so they can save to their desktop

    Perhaps a change like this in your macro would work?

    Please Login or Register  to view this content.
    The macro will now ask for the PC user name.

    Alf

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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