View Full Version : Solved: activx component cant create object excel 2007

06-25-2011, 01:44 AM
searched macros for moving files and i get error429 from all of them :

run time error 429
activx component cant create object

highlighted line :

Set fso = CreateObject("Scripting.FileSystemObject")

here are some codes from web

Sub copy()
Dim Fobj As Object
Set Fobj = CreateObject("Scripting.FileSystemObject")
Fobj.Copyfolder "D:\Data", "D:\Data\New"
End Sub


Sub Copy_Folder()
'This example copy all files and subfolders from FromPath to ToPath.
'Note: If ToPath already exist it will overwrite existing files in this folder
'if ToPath not exist it will be made for you.
Dim fso As Object
Dim FromPath As String
Dim ToPath As String

FromPath = "D:\Data" '<< Change
ToPath = "D:\Test\" & Format(Now, "yyyy-mm-dd h-mm-ss") '<< Change

'If you want to create a backup of your folder every time you run this macro
'you can create a unique folder with a Date/Time stamp.
'ToPath = "C:\Users\Ron\" & Format(Now, "yyyy-mm-dd h-mm-ss")

If Right(FromPath, 1) = "\" Then
FromPath = Left(FromPath, Len(FromPath) - 1)
End If

If Right(ToPath, 1) = "\" Then
ToPath = Left(ToPath, Len(ToPath) - 1)
End If

Set fso = CreateObject("scripting.filesystemobject")

If fso.folderexists(FromPath) = False Then
MsgBox FromPath & " doesn't exist"
Exit Sub
End If

fso.Copyfolder Source:=FromPath, Destination:=ToPath
MsgBox "You can find the files and subfolders from " & FromPath & " in " & ToPath

End Sub


Sub CopyFile()
Dim fso
Dim file As String, sfol As String, dfol As String
file = "*" ' change to match the file name
sfol = "D:\Data" ' change to match the source folder path
dfol = "D:\Data\test" ' change to match the destination folder path
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(sfol & file) Then
MsgBox sfol & file & " does not exist!", vbExclamation, "Source File Missing"
ElseIf Not fso.FileExists(dfol & file) Then
fso.CopyFile (sfol & file), dfol, True
MsgBox dfol & file & " already exists!", vbExclamation, "Destination File Exists"
End If

is there solution for this error in excel 2007

06-25-2011, 04:54 AM
did find solution for my problem (vista,office 2007), if someone needs :
in cmd(admin) run

REGSVR32 C:\Windows\System32\SCRRUN.DLL

and set Microsoft Scripting Runtime in vba editor > tools > references