My code worked before, but now has strange message. The error message is:
'ActiveX component can't create object'
My code is below:
Private Sub cmdExport_Click()
On Error GoTo cmdExport_Err
Dim answer As Integer
Dim fs, d
answer = MsgBox("Insert a disk in A: Ready to export?", vbOKCancel +
vbDefaultButton2)
If answer = 1 Then
' Check to see if A: is ready
Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive("A:")
If d.IsReady Then
DoCmd.TransferDatabase acExport, "dBase IV", "a:\", acQuery,
"ActiveQuery", "Active.dbf"
MsgBox "Export completed"
Else
MsgBox "A: drive is empty. Export canceled"
End If
Else
MsgBox "Export canceled"
End If
cmdExport_Exit:
Exit Sub
cmdExport_Err:
MsgBox Error$
Resume cmdExport_Exit
End Sub
hi Song,
> My code worked before, but now has strange message. The error message is:
> 'ActiveX component can't create object'
Comment out the error handler. At which line does the code execution stops?
> Private Sub cmdExport_Click()
> On Error GoTo cmdExport_Err
> Dim answer As Integer
> Dim fs, d
Better declare fs and d as Object, not as Variant.
> answer = MsgBox("Insert a disk in A: Ready to export?", vbOKCancel +
> vbDefaultButton2)
>
> If answer = 1 Then
> ' Check to see if A: is ready
> Set fs = CreateObject("Scripting.FileSystemObject")
If it stops here, then the Scripting library is not properly installed.
mfG
--> stefan <--
Song Su - 23 Nov 2006 13:52 GMT
Thanks for quick reply. It does stop at createobject. how to reinstall
scripting library?
> hi Song,
>
[quoted text clipped - 19 lines]
> mfG
> --> stefan <--
Stefan Hoffmann - 23 Nov 2006 14:00 GMT
hi Song,
> Thanks for quick reply. It does stop at createobject. how to reinstall
> scripting library?
Reinstall or repair one of the following products:
- Windows Script Host
- VBScript
- Internet Explorer
- Microsoft Office
mfG
--> stefan <--
Song Su - 23 Nov 2006 16:53 GMT
I reinstalled Windows Script Host and problem solved.
Thank you.
> hi Song,
>
[quoted text clipped - 9 lines]
> mfG
> --> stefan <--