Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 260
Default Dir Path Code Problem

Const foldername = "Q:\Stats2004\Contract Reports\Daily
Renewal Audits\March"
'HERE IS THE MAPPED PATH Const foldername = "\\scgvlfs05
\sesfa\Stats2004\Contract Reports\Daily Renewal
Audits\March"

Sub CommandButton1_Click()
Dim FName As String
Dim WB As Workbook
Dim dest As Variant
Dim numcount As Long
Dim numcount2 As Long

numcount = Application.WorksheetFunction.CountA(Workbooks
("abc.xls").Worksheets(1).Range("A:A")) + 2
dest = ("A" & numcount)
ChDir foldername
FName = Dir("*.xls")
MsgBox foldername

Do Until FName = ""
Set WB = Workbooks.Open(FName)
numcount2 = Application.WorksheetFunction.CountA(Workbooks
("abc.xls").Worksheets(1).Range("A:A")) + 2

WB.Worksheets(1).Range("A1:B10").Copy
Destination:=Workbooks("abc.xls").Worksheets(1).Ra nge("A"
& numcount2)
WB.Close savechanges:=False

FName = Dir()
Loop
End Sub

The above code works fine when everything is in a
directory on the C drive but when I tried to change the
path to Q:\ by changing Const foldername = "Q:\Stats2004
\Contract Reports\Daily Renewal Audits\March" it messes
up. For some reason its looking in the P drive and
pulling files from there. I have no idea why its looking
in P instead of Q. I even changed the Const foldername
= "\\scgvlfs05\sesfa\Stats2004\Contract Reports\Daily
Renewal Audits\March" (which is the name of the mapped
drive) and still does not work. Also when I intentionally
changed the path to invalid path the code told me it was
invalid path so I know the code sees the "Q:\Stats2004
\Contract Reports\Daily Renewal Audits\March" which I
specified to be valid. Can anyone please help me?

Thank you

Todd Huttenstine
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Dir Path Code Problem

Hi todd
to change the drive you have to use
ChDrive

ChDir will only change the directory in the current drive


--
Regards
Frank Kabel
Frankfurt, Germany


Todd Huttenstine wrote:
Const foldername = "Q:\Stats2004\Contract Reports\Daily
Renewal Audits\March"
'HERE IS THE MAPPED PATH Const foldername = "\\scgvlfs05
\sesfa\Stats2004\Contract Reports\Daily Renewal
Audits\March"

Sub CommandButton1_Click()
Dim FName As String
Dim WB As Workbook
Dim dest As Variant
Dim numcount As Long
Dim numcount2 As Long

numcount = Application.WorksheetFunction.CountA(Workbooks
("abc.xls").Worksheets(1).Range("A:A")) + 2
dest = ("A" & numcount)
ChDir foldername
FName = Dir("*.xls")
MsgBox foldername

Do Until FName = ""
Set WB = Workbooks.Open(FName)
numcount2 = Application.WorksheetFunction.CountA(Workbooks
("abc.xls").Worksheets(1).Range("A:A")) + 2

WB.Worksheets(1).Range("A1:B10").Copy
Destination:=Workbooks("abc.xls").Worksheets(1).Ra nge("A"
& numcount2)
WB.Close savechanges:=False

FName = Dir()
Loop
End Sub

The above code works fine when everything is in a
directory on the C drive but when I tried to change the
path to Q:\ by changing Const foldername = "Q:\Stats2004
\Contract Reports\Daily Renewal Audits\March" it messes
up. For some reason its looking in the P drive and
pulling files from there. I have no idea why its looking
in P instead of Q. I even changed the Const foldername
= "\\scgvlfs05\sesfa\Stats2004\Contract Reports\Daily
Renewal Audits\March" (which is the name of the mapped
drive) and still does not work. Also when I intentionally
changed the path to invalid path the code told me it was
invalid path so I know the code sees the "Q:\Stats2004
\Contract Reports\Daily Renewal Audits\March" which I
specified to be valid. Can anyone please help me?

Thank you

Todd Huttenstine

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 260
Default Dir Path Code Problem

Alright thank you. That worked. I was going nuts over
here.

-----Original Message-----
Hi todd
to change the drive you have to use
ChDrive

ChDir will only change the directory in the current drive


--
Regards
Frank Kabel
Frankfurt, Germany


Todd Huttenstine wrote:
Const foldername = "Q:\Stats2004\Contract Reports\Daily
Renewal Audits\March"
'HERE IS THE MAPPED PATH Const foldername = "\\scgvlfs05
\sesfa\Stats2004\Contract Reports\Daily Renewal
Audits\March"

Sub CommandButton1_Click()
Dim FName As String
Dim WB As Workbook
Dim dest As Variant
Dim numcount As Long
Dim numcount2 As Long

numcount = Application.WorksheetFunction.CountA

(Workbooks
("abc.xls").Worksheets(1).Range("A:A")) + 2
dest = ("A" & numcount)
ChDir foldername
FName = Dir("*.xls")
MsgBox foldername

Do Until FName = ""
Set WB = Workbooks.Open(FName)
numcount2 = Application.WorksheetFunction.CountA

(Workbooks
("abc.xls").Worksheets(1).Range("A:A")) + 2

WB.Worksheets(1).Range("A1:B10").Copy
Destination:=Workbooks("abc.xls").Worksheets(1).Ra nge

("A"
& numcount2)
WB.Close savechanges:=False

FName = Dir()
Loop
End Sub

The above code works fine when everything is in a
directory on the C drive but when I tried to change the
path to Q:\ by changing Const foldername = "Q:\Stats2004
\Contract Reports\Daily Renewal Audits\March" it messes
up. For some reason its looking in the P drive and
pulling files from there. I have no idea why its

looking
in P instead of Q. I even changed the Const foldername
= "\\scgvlfs05\sesfa\Stats2004\Contract Reports\Daily
Renewal Audits\March" (which is the name of the mapped
drive) and still does not work. Also when I

intentionally
changed the path to invalid path the code told me it was
invalid path so I know the code sees the "Q:\Stats2004
\Contract Reports\Daily Renewal Audits\March" which I
specified to be valid. Can anyone please help me?

Thank you

Todd Huttenstine

.

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
code to reassign a macro to a toolbar button because of path change Almagg via OfficeKB.com Excel Discussion (Misc queries) 0 April 27th 07 06:42 PM
Problem with Import Data path Barry Treadway Excel Discussion (Misc queries) 3 October 5th 05 03:05 PM
Personal.XLS path problem Lenonardo Excel Programming 2 January 10th 04 05:39 PM
File Path Problem Todd Huttenstine[_2_] Excel Programming 3 December 22nd 03 08:44 PM
SendKeys and Path Problem rdcord Excel Programming 3 September 11th 03 06:12 PM


All times are GMT +1. The time now is 12:40 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"