+ Reply to Thread
Results 1 to 8 of 8

VBA to Open a File on ANY Desktop

  1. #1
    Valued Forum Contributor
    Join Date
    03-23-2008
    Location
    Tennessee
    MS-Off Ver
    Office 2007
    Posts
    706

    VBA to Open a File on ANY Desktop

    Greetings, Gurus.

    I am sending this workbook out for several buyers to use. Part of the macro opens a workbook on their desktop named "Backorder List.xls" and copied data to it. The problem is, the way it is written, I have to go around to each buyers computer and edit it so the vba is looking in the right directory for the file. Is there any way to modify this so that it will open the file "Backorder List.xls" no matter who's desktop it is on?

    Please Login or Register  to view this content.
    Thanks in advance for any help you can offer.
    Last edited by hutch@edge.net; 10-20-2009 at 10:22 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA to Open a File on ANY Desktop

    Try this Function to find the Desktop
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: VBA to Open a File on ANY Desktop

    Try changing:
    Please Login or Register  to view this content.
    to:
    Please Login or Register  to view this content.
    and

    Please Login or Register  to view this content.
    to:
    Please Login or Register  to view this content.
    A simple test to show current user:
    Please Login or Register  to view this content.
    Regards

    Rick
    Win10, Office 365

  4. #4
    Valued Forum Contributor
    Join Date
    03-23-2008
    Location
    Tennessee
    MS-Off Ver
    Office 2007
    Posts
    706

    Re: VBA to Open a File on ANY Desktop

    Thanks, guys. I will be testing on multiple computers/configurations today, and wil let you know after troubleshooting.

    Have a good one.

  5. #5
    Valued Forum Contributor
    Join Date
    03-23-2008
    Location
    Tennessee
    MS-Off Ver
    Office 2007
    Posts
    706

    Re: VBA to Open a File on ANY Desktop

    Morning, Guys.

    I tried Rick's suggestion first, because I knew how to incorporate it, but it didn't work on any of the 3 systems I tested it on.

    Roy, I don't know how to use your suggestion. Would I just replace the name, "jerry.hutcheson", with the variable "GetDesktop" in the VBA? Would it have quotes around it, or not?

    Thanks for the help.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA to Open a File on ANY Desktop

    No, just place the code into a Standard Module, then run the test macro. It will return the desktop path.

    Try changing your code
    Please Login or Register  to view this content.
    To
    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor
    Join Date
    03-23-2008
    Location
    Tennessee
    MS-Off Ver
    Office 2007
    Posts
    706

    Re: VBA to Open a File on ANY Desktop

    Thanks, Roy. That seems to work on the machines I've tested it on. After adding the function at the top of a standard module, I had make edit the code a bit. Here's what I came up with:

    Please Login or Register  to view this content.
    Thanks, guys. Have a good one.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA to Open a File on ANY Desktop

    Glad it helped

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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