Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default inconsistent dir() behavior

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_sequen ce_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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default inconsistent dir() behavior

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_sequen ce_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


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
Inconsistent behavior of listboxes vezerid Excel Programming 0 April 29th 08 01:21 PM
Inconsistent behavior using VLOOKUP Andrew[_56_] Excel Programming 4 February 12th 08 10:23 PM
Inconsistent Macro Behavior Sarah K Excel Discussion (Misc queries) 4 November 1st 05 10:36 PM
Inconsistent macro behavior davegb Excel Programming 2 June 21st 05 11:19 PM
Inconsistent Behavior on Web vs. Local Disk D. A. Gray Excel Programming 0 July 27th 03 08:13 PM


All times are GMT +1. The time now is 08:05 AM.

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"