Ask Experts Questions for FREE Help !
Ask
    rsdjimbie's Avatar
    rsdjimbie Posts: 96, Reputation: 3
    Junior Member
     
    #1

    May 4, 2009, 12:47 AM
    File saving macro
    How do I change the following code so all pc's on network can run macro and have it saved on their desktops?

    Code:
    ActiveWorkbook.SaveAs Filename:= _
            "C:\Documents and Settings\User1\Desktop\FAWU", FileFormat _
            :=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
            False, CreateBackup:=False
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #2

    May 4, 2009, 06:37 AM

    Put this two lines of code at the TOP of your macro, one to declare a variable for the Desktop filepath and one to solve for that variable.
    Code:
    Dim DTAddress As String
    DTAddress = CreateObject("WScript.Shell").SpecialFolders("Desktop") & Application.PathSeparator
    Further down in the macro you can now use DTAddress in place of the path, just add the filename:
    Code:
    ActiveWorkbook.SaveAs DTAddress & "FAWU.xls"
    These are the system folders that can be used with "SpecialFolders":
    'Options For special folders
    AllUsersDesktop
    AllUsersStartMenu
    AllUsersPrograms
    AllUsersStartup
    Desktop
    Favorites
    Fonts
    MyDocuments
    NetHood
    PrintHood
    Programs
    Recent
    SendTo
    StartMenu
    Startup
    Templates
    rsdjimbie's Avatar
    rsdjimbie Posts: 96, Reputation: 3
    Junior Member
     
    #3

    May 4, 2009, 07:20 AM

    Thank you, works very well.
    JB you helped me so much, you are an insperation, so I have orderd myself VBA for Excel for dummies as a start.
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #4

    May 4, 2009, 09:07 AM

    Glad to be of aid. I've never used that myself, but the internet is a wicked fast research tool... found that for you with just a little digging and testing.

    I learned something useful myself in the process and now have SpecialFolders() as a permanent technique in my arsenal... thanks to you!

    Cheers.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Saving in Same File [ 1 Answers ]

Anyone who could help me I'd really appreciate it! I know nothing about computers at all. I scanned two images and saved them in the correct format in the same folder. How do I save them in the same file?

Saving a video file from a website [ 7 Answers ]

Is there a way to copy and save an online video clip (as in You Tube) as a file that I can save and keep, as opposed to a link to a site? (A .wmv type file?)


View more questions Search