Scripting.FileSystemObject stopped working

B

Budget Programmer

Hello,

For a year and a half I've had an Excel macro working fine. I haven't
changed anything to the PC that would affect Excel, to my knowledge.
I'm running Vista 32 Home Premium and Office 2007.
I have the following references checked in "Tools / References":
- Visual Basic for Applications
- Microsoft Excel 12.0 Object Library
- OLE Automation
- Microsoft Office 12.0 Object Library

This code runs on other PC's, but it stopped running on this (essential) one.
When it encounters the first SET statement, it give the error:
"Run-time error '429':
ActiveX component can't create object"

Sub CreateEditedSongListing()
'DECLARE VARIABLES
Dim objFSO As Object
Dim objFolder As Object
Dim strSongs_EditedPath As String

'ASSIGN INITIAL VALUES

strSongs_EditedPath = "C:\Users\Phil\Documents\Songbook On
Screen\Songs-Edited"

'Use Microsoft Scripting runtime.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strSongs_EditedPath)
End Sub

In which reference is the "Scripting.FileSystemObject" located?
The code snipet runs fine on another PC, which has the same four references
checked. However it stopped runing on the essential PC.
Thanks for looking into this.
Phil
 
P

Peter T

Maybe Scripting has been disabled by the administrator in that machine

Regards,
Peter T
 
B

Budget Programmer

Peter,
Are you speaking of Virus Protection Software or some other system setting?
I'm not quite sure what you mean. I'm the only one that uses the machine,
but maybe some update or something changed it. Where should I look?
Thanks.
Phil
 
P

Peter T

If you are the only user then it sounds like it has not been disabled.
(Though it is one component admin's sometimes want to disable in a corporate
environment).

In Tools References look for "Microsoft Scripting Runtime" and tick it. Add
the following and run it

Sub test()
Dim objFSO As Object
Dim fso As Scripting.FileSystemObject

Set fso = New Scripting.FileSystemObject

MsgBox fso.Drives.Count, , "fso New"
Set fso = Nothing

Set fso = CreateObject("Scripting.FileSystemObject")
MsgBox fso.Drives.Count, , "fso CreateObject"

Set fso = Nothing

Set objFSO = CreateObject("Scripting.FileSystemObject")
MsgBox objFSO.Drives.Count, , "objFSO CreateObject"

End Sub

Report back if all/some/none of the above tests worked, or if you couldn't
even set the reference.

Regards,
Peter T
 
B

Budget Programmer

Hi Peter,
Before doing anything, I ran stepped through your code. It stopped at the
DIM FSO statement. Initially, I couldn't a reference for "Microsoft
Scripting Runtime". I went to another PC and found that the reference is
located in file "C:\Windows\System32\scrrun.dll" I browesed for that and was
able to add the reference. (It's interesting that I had to browse for it.)

However, At the SET statement I get the same error:
"Run-time error '429':
ActiveX component can't create object"

Thanks for your help.
I'm still at a loss.
Phil
 
P

Peter T

Try re-registering scrrun.dll.
Windows start, Run, enter the following and hit enter
regsvr32 scrrun.dll

As the dll is in the system folder it should get found and registered and
you'll get a Success message. If not try browsing to it and try again

If it fails to register or still doesn't work it's probably a 'permissions'
issue, though not sure why as you are the only user. I don't recall where to
look in the registry but I imagine there's plenty 'out there'.

Thinking about regsvr32 again, in Vista I expect you will need to log on as
administrator and maybe turn off the UAC (not sure)

Regards,
Peter T
 
B

Budget Programmer

Peter,
Re-registering scrrun.dll fixed the problem. Many thanks.

When I ran it straight from the "start" button, I got an error. I had to go
Start / Programs / Accessories then I right-clicked on Command Prompt and
selected "Run As Administrator" It registered successfully and the Macro ran
as before. I have no idea how scrrun.dll got unregistered, but that fixed it.

(BTW, this site's e-mail notifications aren't working today. Also, the
"index" for the Search For field doesn't seem to be updated).

Again, Many Many thanks.
Phil
 
P

Peter T

Glad it worked and thanks for the feedback.
(BTW, this site's e-mail notifications aren't working today. Also, the
"index" for the Search For field doesn't seem to be updated).

Neither of these have worked in "WebNews" for ages, there are other ways
though to access these groups.

Regards,
Peter T
 

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