default location for files open commands

E

Eric Dreshfield

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 !
 
T

Tom Ogilvy

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"
 
E

Eric Dreshfield

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 !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top