strange error message

S

Song Su

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
 
S

Stefan Hoffmann

hi Song,

Song said:
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 <--
 
S

Song Su

Thanks for quick reply. It does stop at createobject. how to reinstall
scripting library?
 
S

Stefan Hoffmann

hi Song,

Song said:
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 <--
 

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