Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Help with paths

Hi.


Do I need to use the full path in VBA code i.e.

GetSheet = "FTP " & DailyDate
Set wb = Workbooks.Open("C:\Users\***\***\****\Archives")
Windows("Archives").Activate
Sheets(GetSheet).Select
Sheets(GetSheet).Copy After:=Workbooks("Daily Reports.xls").Sheets(1)
wb.Close False


this if fine while under development on one pc. The code will have a number
of workbooks in one folder on a network. It will be accessed by a number of
pc's. can I shorten this path so that it just looks in the folder where all
the workbooks will be stored?

Thanks,

Albert

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Help with paths

If you omit the path information from the file name, the Open procedure will
look in the current default directory. You can retrieve the full path of
the current directory with

Dim S As String
S = CurDir
MsgBox S

You can change the current directory with code like

ChDrive "G:\Test"
ChDir "G:\Test"


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




"Albert Browne" wrote in message
...
Hi.


Do I need to use the full path in VBA code i.e.

GetSheet = "FTP " & DailyDate
Set wb = Workbooks.Open("C:\Users\***\***\****\Archives")
Windows("Archives").Activate
Sheets(GetSheet).Select
Sheets(GetSheet).Copy After:=Workbooks("Daily Reports.xls").Sheets(1)
wb.Close False


this if fine while under development on one pc. The code will have a
number of workbooks in one folder on a network. It will be accessed by a
number of pc's. can I shorten this path so that it just looks in the
folder where all the workbooks will be stored?

Thanks,

Albert


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Help with paths

If all the workbooks, including the one with the VBA, are stored in the same
folder, then you can use the path of the active workbook:

Sub browne()
s1 = ActiveWorkbook.Path
s2 = "\B.xls"
Workbooks.Open s1 & s2
End Sub

will open b.xls in the common folder.
--
Gary''s Student - gsnu200804


"Albert Browne" wrote:

Hi.


Do I need to use the full path in VBA code i.e.

GetSheet = "FTP " & DailyDate
Set wb = Workbooks.Open("C:\Users\***\***\****\Archives")
Windows("Archives").Activate
Sheets(GetSheet).Select
Sheets(GetSheet).Copy After:=Workbooks("Daily Reports.xls").Sheets(1)
wb.Close False


this if fine while under development on one pc. The code will have a number
of workbooks in one folder on a network. It will be accessed by a number of
pc's. can I shorten this path so that it just looks in the folder where all
the workbooks will be stored?

Thanks,

Albert


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
Paths for macros Tendresse Excel Discussion (Misc queries) 15 August 8th 07 02:50 AM
Paths Ross[_2_] New Users to Excel 1 April 4th 07 11:35 PM
file paths hr Excel Discussion (Misc queries) 0 December 7th 05 04:59 PM
UNC Paths Paul Smith[_3_] Excel Programming 1 February 18th 05 12:00 PM


All times are GMT +1. The time now is 03:47 PM.

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

About Us

"It's about Microsoft Excel"