Activex error when using FileSystemObject

S

stephenc

I've hit this problem recently in a subroutine, with code that has been
running fine for several years. I can't see what's changed in my system to
cause the problem. Very occasionally, the code works without error, but I
have not been able to find out why. Obviously, I have setup a reference to
"Microsoft Scripting Runtime".

Here's the exact error:

Run-time error '429':
ActiveX component can't create object

Dim fso As New Scripting.FileSystemObject
Set fso = New FileSystemObject '<< crashes here

I'm using Word 2002.
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?c3RlcGhlbmM=?=,

Don't use New twice. Personally, I'd take it out of the Dim line and leave it
in the Set line.
I've hit this problem recently in a subroutine, with code that has been
running fine for several years. I can't see what's changed in my system to
cause the problem. Very occasionally, the code works without error, but I
have not been able to find out why. Obviously, I have setup a reference to
"Microsoft Scripting Runtime".

Here's the exact error:

Run-time error '429':
ActiveX component can't create object

Dim fso As New Scripting.FileSystemObject
Set fso = New FileSystemObject '<< crashes here

I'm using Word 2002.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
S

stephenc

Thanks for replying Cindy.
I changed...
Dim fso As New Scripting.FileSystemObject
....to...
Dim fso As Scripting.FileSystemObject
....and removed...
Set fso = New FileSystemObject

....and now it works fine. I don't understand why it used to work, but yoou
have shown me that my code was bad anyway. Thanks very much for helping out.
Big respect to the MVPs. Much appreciated :)

StephenC
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?c3RlcGhlbmM=?=,
now it works fine. I don't understand why it used to work, but yoou
have shown me that my code was bad anyway. Thanks very much for helping out.
Big respect to the MVPs. Much appreciated :)
You're most welcome. Thank you for letting me know that worked :) I suspect it
ran OK before due to some loop-hole or other that the developers found and
closed between version. Essentially, what you were doing was
- declaring and creating an instance of the FileSystemObject
- setting the same object variable to yet a second instance
- destroying one of those instances
- but not the other
- thus leaving an instance in memory (memory leak) that wasn't allowing
things to work next time around

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

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