sdbenner


I am trying to use Excel VBA to open a folder and populate an array variable with all the word doc filenames in the folder. I am getting an "ActiveX component can't create object" error on the following code, specifically the Dialogs(wdDialogFileOpen) line, and I'm struggling to figure it out. Any suggestions

Public Sub Main()

Dim FileArray() As String, ffile As String, ffldr As String, curDoc As String, Count As Integer
Count = 1

' Navigate to a particular folder
With Dialogs(wdDialogFileOpen)
.Name = "*.doc"
.Show
End With

Thanks,
Steve.



Re: Common Dialog error...

ADG


Hi

I don't think wdDialogFileOpen is a contstant in Excel , try retyping the line and check the available constants in the list

Regards

ADG






Re: Common Dialog error...

Shasur

Hi

MyDialog = Application.Dialogs(xlDialogOpen).Show

Should get you the dialog

However, since your aim is to get the directory of the Doc files it would be better to get that using Browse Folder dialog. I have specified the link below:

http://vbadud.blogspot.com/2007/04/browse-folder-select-folder-thru-shell.html

Cheers

Shasur