help with common dialog for multiple file insert please

V

voip1234

I wrote some code to let me select multiple files, then organize them
in
the order I want using listboxes and finally inserting.
For the common dialog stuff I used the code kindly
provided by Jonathan West on the following thread
http://groups-beta.google.com/group/microsoft.public.word.vba.customization/msg/4f5145a2b1e13e12

Everything works according to the way it was designed to work.
Jonathan says
"If you select multiple files, the first entry in the listbox is the
folder
they were selected from, and the other entries are the names of the
selected
files. If a single file is selected, the full pathname is returned."

which is exactly what it does.
I would like it to behave the exact same way for one or multiple
files. Specifically I would like it to provide the path as the first
entry and the second as the file name even when only selecting
one file. I have looked at the common dialog code he wrote, but
cant figure out where this is an option if there actually is
one (i am new to vba). I was also told to parse the line when
it comes in as path and file name together, but I dont know how to
do this either.

I am guessing it has to be an option on the common dialog, and
I see a section that says
----------------
'put the members of the returned sFile
'string into an array. If multiselect,
'the first member is the path, and the
'remaining members are the files under
'that path selected.
ReDim vFileList(0)
iFileTotal = 0
Do While Len(buff) > 3
ReDim Preserve vFileList(iFileTotal)
vFileList(iFileTotal) = StripDelimitedItem(buff, vbNullChar)
iFileTotal = iFileTotal + 1
Loop

FileOpenDialog = vFileList
Else
FileOpenDialog = ""
End If

End Function

Private Function StripDelimitedItem(startStrg As String, _
delimiter As String) As String
----------------

which i guess is where the secret is....but can somebody
help me figure out what to change...i want path on first
entry and filename on the following listbox entries whether it was
multiselection or not.

thanks!!!!
 
V

voip1234

thanks for the quick reply.
could you then please explain to me how one goes about "parsing" the
entry so that I can have the path on one variable and the filename on
another? I am guessing I should analyze the text from right to left
until the first '\' but I dont even know where to start to get it to do
that.
thanks!!
 
V

voip1234

thanks for the quick reply.
could you then please explain to me how one goes about "parsing" the
entry so that I can have the path on one variable and the filename on
another? I am guessing I should analyze the text from right to left
until the first '\' but I dont even know where to start to get it to do
that.
thanks!!
 
V

voip1234

thanks again Jezebel, that is very helpful, I will try it inmediately.
Would you mind explaining how the command is working?
thanks again!!!!
 
V

voip1234

thanks Jezebel...now I understand what its doing. I tried it but it
didnt work though.
After fiddling around with it and a few msgboxes to figure out what is
wrong
i found that the code to call the open dialog box defines the length of
the title and filename with a huge number of spaces, so when I do the
substraction, its a huge number minus a not so huge number which equals
the whole path and filename minus a few spaces....i.e. the resultant of
the path statement is the same as both path and filename.
I guess now I have to figure out how to strip off the spaces for the
Len statements to actually work.
thanks,
 
V

voip1234

I just tried RTrim, LTrim, and Trim, but none of them helped....any
suggestions on what I can try next?
thank you.
 
V

voip1234

once again you were right....it was Null chraracters that were
affecting the
behavior.
After a while of trying out to delete the characters using the few
commands I know,
i ended up doing a search and found the following code....which worked
-------------------
Private Function CTrim(s As String) As String
Dim l As Long
l = InStr(s, Chr$(0))
If l > 0 Then
CTrim = Left$(s, l - 1)
Else
CTrim = s
End If
End Function
 
V

voip1234

i was about to ask about the $ and why some examples showed it with and
others without...but i decided not to as I had already asked a bunch of
questions....

about the replace command.....
i suppose that would work in my case but by adding an additional Trim
so it becomes something like
NewString = Trim$(Replace$(OldString, Chr$(0), ""))
as there are additional spaces in there after the null characters are
gone.
thanks for all your help
(back to work....now I have to figure out how to put the path on one
column in a listbox and the filename on another column)
 

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

Top