Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default default location for files open commands

I have the following code in a a macro:

ChDir "N:\pay\payroll\positive pay"
myfile = Application.GetOpenFilename("Text Files,*.txt")
Workbooks.OpenText FileName:=myfile, StartRow:=1,_
DataType:=xlDelimited, TextQualifier:=xlDoubleQuote,_
ConsecutiveDelimiter:=True, Tab:=True,_
Semicolon:=False, Comma:=False, Space:=True,_
Other:=False, FieldInfo:=Array(Array(1, 1),_
Array(2, 1), Array(3, 1))

Everytime I execute the macro it does not start the open
file command from N:\pay\payroll\positive pay....it starts
from what ever folder I last had excel looking in. Did I
not code this correctly ?

Thanks !


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default default location for files open commands

Each drive has a default directory.

ChDir "N:\pay\payroll\positive pay"

changes the default directory for the N drive, but if another drive is the
default drive, you will open in the default directory for that drive. To
make N the default drive as well

ChDrive "N"
ChDir "N:\pay\payroll\positive pay"


or
ChDrive "N:\pay\payroll\positive pay" ' uses first character in the string
ChDir "N:\pay\payroll\positive pay"

--
Regards,
Tom Ogilvy

"Eric Dreshfield" wrote in message
...
I have the following code in a a macro:

ChDir "N:\pay\payroll\positive pay"
myfile = Application.GetOpenFilename("Text Files,*.txt")
Workbooks.OpenText FileName:=myfile, StartRow:=1,_
DataType:=xlDelimited, TextQualifier:=xlDoubleQuote,_
ConsecutiveDelimiter:=True, Tab:=True,_
Semicolon:=False, Comma:=False, Space:=True,_
Other:=False, FieldInfo:=Array(Array(1, 1),_
Array(2, 1), Array(3, 1))

Everytime I execute the macro it does not start the open
file command from N:\pay\payroll\positive pay....it starts
from what ever folder I last had excel looking in. Did I
not code this correctly ?

Thanks !




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default default location for files open commands

Tom,

Thanks....I now need to have a conversation with the
person whose macro I cloned that faulty coding from and
have them change their own macro so that it will work
consistently.

I'm so glad I found this newsgroup...it has been a wealth
of knowledge !

Thanks !
-----Original Message-----
Each drive has a default directory.

ChDir "N:\pay\payroll\positive pay"

changes the default directory for the N drive, but if

another drive is the
default drive, you will open in the default directory for

that drive. To
make N the default drive as well

ChDrive "N"
ChDir "N:\pay\payroll\positive pay"


or
ChDrive "N:\pay\payroll\positive pay" ' uses first

character in the string
ChDir "N:\pay\payroll\positive pay"

--
Regards,
Tom Ogilvy

"Eric Dreshfield" wrote in message
...
I have the following code in a a macro:

ChDir "N:\pay\payroll\positive pay"
myfile = Application.GetOpenFilename("Text Files,*.txt")
Workbooks.OpenText FileName:=myfile, StartRow:=1,_
DataType:=xlDelimited, TextQualifier:=xlDoubleQuote,_
ConsecutiveDelimiter:=True, Tab:=True,_
Semicolon:=False, Comma:=False, Space:=True,_
Other:=False, FieldInfo:=Array(Array(1, 1),_
Array(2, 1), Array(3, 1))

Everytime I execute the macro it does not start the open
file command from N:\pay\payroll\positive pay....it

starts
from what ever folder I last had excel looking in. Did

I
not code this correctly ?

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
Excel will not open in default file location Roger Chapman Excel Discussion (Misc queries) 2 December 8th 10 04:58 PM
How to change default Open/Files of Type to "Microsoft Excel Files Tammy Excel Discussion (Misc queries) 2 January 14th 08 11:06 PM
how do i change the default location of my picture files in Excel Rosie D Excel Discussion (Misc queries) 2 June 4th 06 11:43 AM
i couldn't open my excel files,it gives location couldn't find err Hozefa Excel Discussion (Misc queries) 1 December 21st 05 04:06 PM
How do I change the default location for importing text files? BWTreadway Excel Discussion (Misc queries) 0 September 30th 05 06:39 PM


All times are GMT +1. The time now is 11:53 AM.

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"