Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Getting/using the File path of a spreadsheet

I am trying to automate the linking of data in 20 spreadsheets into a
separate spreadsheet.

They are all saved in a single folder which changes each month so I can not
"hard wire" the path name in.

This is not a problem if the user opens the summary spreadsheet using
File/Open as this tells Excel the current file path (the same as where the
data is kept).

However, it is done over a very large network and most users find it easier
to open the summary spreadsheet from an Explorer Window oe desk top shortcut.
The default file path may have changed (normally My Documents first thing in
the morning) and the data will not link.

Is there a way of getting the file path from the Summary spreadsheet when it
is opened and reseting the default path to that, so that the data will link
when the user manually presses a "Link Data" button.(I can then turn off the
startup prompt for linking data which is confusing some users).

Many thanks.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Getting/using the File path of a spreadsheet

Hi,

The PATH attribute for thisworkbook gives you the info you want
Then u may either change directory to that path, or maybe better, explicitly
append the path to the workbooks you want to summarize

Here after an example on how to change the current path to the workbook path

Private Sub Workbook_Open()
MsgBox "Before : Current path is " & CurDir()
Set fs = CreateObject("Scripting.FileSystemObject")
' getting the workbook path (Note : it is the workbook path and not the
link Path)
wbpath = ThisWorkbook.Path
' gets the drive out of the path
drive = fs.getdrivename(wbpath)
' need to both change drive and change path
ChDrive drive
ChDir wbpath
MsgBox "After : Current path is " & CurDir(drive)
End Sub

Truly yours,

René

"B Baggins" a écrit dans le message de
news: ...
I am trying to automate the linking of data in 20 spreadsheets into a
separate spreadsheet.

They are all saved in a single folder which changes each month so I can
not
"hard wire" the path name in.

This is not a problem if the user opens the summary spreadsheet using
File/Open as this tells Excel the current file path (the same as where the
data is kept).

However, it is done over a very large network and most users find it
easier
to open the summary spreadsheet from an Explorer Window oe desk top
shortcut.
The default file path may have changed (normally My Documents first thing
in
the morning) and the data will not link.

Is there a way of getting the file path from the Summary spreadsheet when
it
is opened and reseting the default path to that, so that the data will
link
when the user manually presses a "Link Data" button.(I can then turn off
the
startup prompt for linking data which is confusing some users).

Many thanks.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
File Path Too Long? Not Anymore! Check out Long Path Tool Max Loger Excel Discussion (Misc queries) 1 March 24th 17 07:59 AM
Disable spreadsheet when copied to incorrect file path or differen ip address Schatzi Excel Discussion (Misc queries) 4 April 29th 11 02:58 PM
Is there a function to print file name/path on a spreadsheet? cchas80860 Excel Worksheet Functions 4 April 14th 09 02:35 AM
Formula too long - new file path is shorter than old file path - Excel 2003 Greg J Excel Worksheet Functions 1 November 22nd 06 05:16 PM
Find Folder Path + file Name Length and Insert into Spreadsheet Steve Roberts Excel Programming 1 July 26th 05 06:01 PM


All times are GMT +1. The time now is 04:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"