inconsistent dir() behavior

  • Thread starter Thread starter ken23508
  • Start date Start date
K

ken23508

I have a userform with a listbox that is populated with all the files in a particular folder whenever the userform is initiated. On my computer, and on most of my clients computer's the following code works perfectly:

Private Sub UserForm_Initialize()

Dim fn As String

Set R = ThisWorkbook.Worksheets("seqlog").Range("db_sequence_log")

TextBox3.Text = Sheet10.Range("Location_Seq").Value

ChDir (Sheet10.Range("Location_Seq").Value)

fn = Dir("*.*")

'polulate sequence listbox with all files from directory in Textbox3

Do While fn <> ""
ListBox1.AddItem fn
fn = Dir()
Loop

then some more stuff,

On a couple computers, on the same network, when opening the same copy of the file from the same location, and with the same version of windows, office, excel, set up by the same it department, using the same licenses the form behaves differently. Instead of loading the files from the folder identified in the worksheet range the listbox is populated with the files in the user's mydocuments directory. This can be avoided if the file is saved after opening, without doing anything; just open the file, ctrl-s, then trigger the form and it works.

Any ideas about what could be different? What have I missed?

thanks
Ken
 
I have a userform with a listbox that is populated with all the files
in a particular folder whenever the userform is initiated. On my
computer, and on most of my clients computer's the following code
works perfectly:

Private Sub UserForm_Initialize()

Dim fn As String

Set R =
ThisWorkbook.Worksheets("seqlog").Range("db_sequence_log")

TextBox3.Text = Sheet10.Range("Location_Seq").Value

ChDir (Sheet10.Range("Location_Seq").Value)

fn = Dir("*.*")

'polulate sequence listbox with all files from directory in Textbox3

Do While fn <> ""
ListBox1.AddItem fn
fn = Dir()
Loop

then some more stuff,

On a couple computers, on the same network, when opening the same
copy of the file from the same location, and with the same version of
windows, office, excel, set up by the same it department, using the
same licenses the form behaves differently. Instead of loading the
files from the folder identified in the worksheet range the listbox
is populated with the files in the user's mydocuments directory.
This can be avoided if the file is saved after opening, without doing
anything; just open the file, ctrl-s, then trigger the form and it
works.

Any ideas about what could be different? What have I missed?

thanks
Ken

Try putting the ChDir in the routine that loads the userform and see
what behavior results!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
Back
Top