ActiveX can't create object

J

JeroenM

I need an overview of all .vsd files in a certain directory, and for each
..vsd file the name of the seperate pages. I want to create this overview in
Excel using the following VBA code:

Dim vsoDoc As Visio.Document
Dim vsoPag As Visio.Page
Dim vsoPags As Visio.Pages

With Application.FileSearch
.NewSearch
.LookIn = FolderPath
.SearchSubFolders = True
.FileName = "*.vsd"
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
End With

With Application.FileSearch

For i = 1 To .FoundFiles.Count

Set vsoDoc = Visio.Application.Documents.Open(FileName)
Set vsoPags = vsoDoc.Pages

For Each vsoPage In vsoPages
…………
Next

Next i

End With

Set vsoDoc = Nothing
Set VsoPags = Nothing
Set vsoPag = Nothing

When I run the VBA code in Excel it gives me the following message: Error
429 / ActiveX can't create object. This error appears on the following line:
"Set vsoDoc = Visio.Application.Documents.Open(FileName)".

I already made a reference to the following library: Microsoft Visio 11.0
Type Library, but that didn't help.

Who can help me?

Thanks, JeroenM.
 
A

AlEdlund

AFAICS, since I get easily confused in vba, where do you define the Visio
app/ create it?
al
 
A

AlEdlund

specifically I was looking for something like this

dim visApp as visio.application
set visApp = createobject(visio.application)

You're playing inside of excel which has it's own (different) application.
al
 
J

JeroenM

Thanks,

Yes indeed this was the mistake I made. I added the code and now it works.

JeroenM.
 

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