Log in

View Full Version : Open file, read fille names using VBA for Word



jspattavina
08-20-2010, 07:44 AM
I have a WORD UserForm that pops up. When the GetLatest button is clicked I want to:

(A) Open a file in another director and display files there
(B) read and save the file names in that directory.

Any help on how to do A and B

fumei
08-20-2010, 12:50 PM
"read and save the file names"

read and save....where? As an array of strings?

BTW: A is two very different things. Open a file is one. Displaying files is quite another.

jspattavina
09-13-2010, 02:21 PM
"read and save the file names"

read and save....where? As an array of strings?

BTW: A is two very different things. Open a file is one. Displaying files is quite another.
I am using the

---------------------------------

I am using the following code and it seems to work.

Thanks!

CODE:
Dim sPath As String
With ActiveDocument
' Get filename
With Application.Dialogs(wdDialogFileOpen)
.Display
sFileName = .Name
End With
' Read .ris file
fText = ReadTextFile(sFileName)
' parse .ris file
fileStr = ParseRIS(fText)
' display .ris file and file name
fText = fileStr
SourceName = sFileName ' show filename in textbox
End With