+ Reply to Thread
Results 1 to 4 of 4

macro to retrieve path to opened file

  1. #1
    windsurferLA
    Guest

    macro to retrieve path to opened file

    Help would be appreciated getting the syntax correct in an XL97 macro
    under WinXP. I working on building code that is to be part of a larger
    macro that will save the current version of a spreadsheet and ripple
    down prior versions of that spreadsheet, yet not be dependent on the
    spreadsheet having a specific name or location.

    If one opens an Excel file by selecting (double clicking) its name in a
    directory, how does one find the path to that file using a command
    within a macro associated with that Excel file?

    Ultimately I want to place a SaveAs command with provisions for a backup
    in an Auto_Close() macro, but the SaveAs command saves the file to the
    “current directory” which is not necessarily the directory containing
    the original file.

    Thanks .. WindsurferLA

  2. #2
    Glen Mettler
    Guest

    Re: macro to retrieve path to opened file

    One way:

    Sub Auto_Open
    MyPath = ActiveWorkbook.Path
    ChDir MyPath
    End Sub

    Glen

    "windsurferLA" <buczacz@yahoo.com> wrote in message
    news:I7idnXeNrIkZXY7fRVn-pg@comcast.com...
    > Help would be appreciated getting the syntax correct in an XL97 macro
    > under WinXP. I working on building code that is to be part of a larger
    > macro that will save the current version of a spreadsheet and ripple down
    > prior versions of that spreadsheet, yet not be dependent on the
    > spreadsheet having a specific name or location.
    >
    > If one opens an Excel file by selecting (double clicking) its name in a
    > directory, how does one find the path to that file using a command within
    > a macro associated with that Excel file?
    >
    > Ultimately I want to place a SaveAs command with provisions for a backup
    > in an Auto_Close() macro, but the SaveAs command saves the file to the
    > “current directory” which is not necessarily the directory containing the
    > original file.
    >
    > Thanks .. WindsurferLA




  3. #3
    windsurferLA
    Guest

    Re: macro to retrieve path to opened file

    Glen ... once I saw your reply, I said to myself "obvious," but I have
    not found it in any of my Excel VBA books.

    Thanks .. WindsurferLA

    Glen Mettler wrote:
    > One way:
    >
    > Sub Auto_Open
    > MyPath = ActiveWorkbook.Path
    > ChDir MyPath
    > End Sub
    >
    > Glen
    >
    > "windsurferLA" <buczacz@yahoo.com> wrote in message
    > news:I7idnXeNrIkZXY7fRVn-pg@comcast.com...
    >
    >>Help would be appreciated getting the syntax correct in an XL97 macro
    >>under WinXP. I working on building code that is to be part of a larger
    >>macro that will save the current version of a spreadsheet and ripple down
    >>prior versions of that spreadsheet, yet not be dependent on the
    >>spreadsheet having a specific name or location.
    >>
    >>If one opens an Excel file by selecting (double clicking) its name in a
    >>directory, how does one find the path to that file using a command within
    >>a macro associated with that Excel file?
    >>
    >>Ultimately I want to place a SaveAs command with provisions for a backup
    >>in an Auto_Close() macro, but the SaveAs command saves the file to the
    >>“current directory” which is not necessarily the directory containing the
    >>original file.
    >>
    >>Thanks .. WindsurferLA

    >
    >
    >

    Thanks...

  4. #4
    Myrna Larson
    Guest

    Re: macro to retrieve path to opened file

    Next time, try Help <g>. Specifically, in the immediate window, you could have
    typed 'path' (without the quotes) and pressed F1 to find several relevant
    topics.


    On Thu, 17 Feb 2005 07:49:35 -0800, windsurferLA <buczacz@yahoo.com> wrote:

    >Glen ... once I saw your reply, I said to myself "obvious," but I have
    >not found it in any of my Excel VBA books.
    >
    >Thanks .. WindsurferLA
    >
    >Glen Mettler wrote:
    >> One way:
    >>
    >> Sub Auto_Open
    >> MyPath = ActiveWorkbook.Path
    >> ChDir MyPath
    >> End Sub
    >>
    >> Glen
    >>
    >> "windsurferLA" <buczacz@yahoo.com> wrote in message
    >> news:I7idnXeNrIkZXY7fRVn-pg@comcast.com...
    >>
    >>>Help would be appreciated getting the syntax correct in an XL97 macro
    >>>under WinXP. I working on building code that is to be part of a larger
    >>>macro that will save the current version of a spreadsheet and ripple down
    >>>prior versions of that spreadsheet, yet not be dependent on the
    >>>spreadsheet having a specific name or location.
    >>>
    >>>If one opens an Excel file by selecting (double clicking) its name in a
    >>>directory, how does one find the path to that file using a command within
    >>>a macro associated with that Excel file?
    >>>
    >>>Ultimately I want to place a SaveAs command with provisions for a backup
    >>>in an Auto_Close() macro, but the SaveAs command saves the file to the
    >>>“current directory” which is not necessarily the directory containing the
    >>>original file.
    >>>
    >>>Thanks .. WindsurferLA

    >>
    >>
    >>

    >Thanks...



+ 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