# VBScript error number 0x080070002



## MickHH (Aug 24, 2011)

hi,
recently our company has upgraded from XP to Windows 7.
A VBscript that used to run as a macro within a program called Atoll no longer works.
I get the error "Error Number 0x80070002, line 88

the program displays an objExplorer (Internet explorer application) to get data input then carries out the rest of the script. The program is displaying the explorer window but is falling over straight after (without selecting anything)

I have tried: 
registering VBscript in the registry
loading framework 4 for clients

Any ideas?


----------



## Keebellah (Mar 27, 2008)

have you debugged the script?
What does that line of code do?
If you ceheck in Google, one of the many error messages is
*Error Description: The system cannot find the file specified*
Well maybe the macro is invoking a file that no longer exists.


----------



## MickHH (Aug 24, 2011)

thanks Keebellah, I should have added more info

This is the segment of code in question:

Set WshShell = CreateObject("WScript.Shell")
Set WshEnv = WshShell.Environment("PROCESS")
tmpFile = WshEnv("TEMP") & "\dialog.htm"
Set WshEnv = Nothing

' Create dialog box
GenDialogHTML tmpFile

Set objExplorer = CreateObject("InternetExplorer.Application")
objExplorer.Navigate "file:///" & tmpFile
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width = 600
objExplorer.Height = 400
objExplorer.Visible = 1

' WshShell.Run "sleep 1", 0, true ' this fixs the problem better then the msgbox below

' MsgBox "Just waiting a moment, now please click okay and then switch to " _
' & Chr(10) & _
' "the ""Copy Site to ACMA - Microsoft Internet Explorer"" window!", _
' vbOKOnly + vbInformation , "ACMA Copy"

objExplorer.Document.All.Item("OK").Onclick = GetRef("OK_CB2")
objExplorer.Document.All.Item("Cancel").Onclick = GetRef("Cancel_CB2")

' Wait for dialog box
complete = 0
Do While complete = 0
WshShell.Run "sleep 1", 0, true
Loop

Set WshShell = Nothing

-----

The problem is in the WshShell.Run "sleep 1", 0, true
So I think that WshShell is the problem.
Does this still work in Windows 7?


----------



## Keebellah (Mar 27, 2008)

I'n no vb guru but the messag I get, beside the error is invalid data and that's because I don't have dialog.htm so the tmpFile vvalue is null blank, no go.

Could this be the reason?

Do you have a sample of *dialog.htm*


----------



## MickHH (Aug 24, 2011)

im not sure i understand Hans. Do i have a copy of diaslog.htm on my computer?


----------



## MickHH (Aug 24, 2011)

oh ok now i follow: yes I do.
I create the dialog further down in my code and it appears on my screen along with the error.

The code for the dialog box is:

Private Sub GenDialogHTML( tmpFile )
'
' Generate HTML code used to build dialog box
'
Dim fso, Myfile, doc

Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile( tmpFile, True)

MyFile.WriteLine("")
MyFile.WriteLine("")
MyFile.WriteLine("Copy Site to ACMA (Version 7.0)")
MyFile.WriteLine("")
MyFile.WriteLine("")
MyFile.WriteLine("")
MyFile.WriteLine("")
MyFile.WriteLine("
*Copy Site to ACMA Project (Ver 7.0)*
")

MyFile.WriteLine(" Source Project: ")
MyFile.WriteLine(" ")
MyFile.WriteLine(" Select Project")
MyFile.WriteLine(" ---------")
For Each doc In Atoll.Documents
MyFile.WriteLine(" " & _
doc.Name & "")
Next
MyFile.WriteLine("

")

MyFile.WriteLine(" Destination Project: ")
MyFile.WriteLine(" ")
MyFile.WriteLine(" Select Project")
MyFile.WriteLine(" ---------")
For Each doc In Atoll.Documents
MyFile.WriteLine(" " & doc.Name & "")
Next
MyFile.WriteLine("

")
MyFile.WriteLine(" Enter site code: ")
MyFile.WriteLine("

")
' MyFile.WriteLine(" ** Case sensitive!

")
MyFile.WriteLine(" ")
MyFile.WriteLine(" ")
MyFile.WriteLine(" ")
MyFile.WriteLine("

When completed, click OK (or Cancel to abort), then switch back to Atoll and click OK to continue.")
MyFile.WriteLine("")
MyFile.WriteLine("")
MyFile.WriteLine("")

MyFile.Close
Set MyFile = Nothing
Set fso = Nothing

End Sub


----------



## Keebellah (Mar 27, 2008)

Okay, it's getting better, I get an error on the line

*For Each doc In Atoll.Documents*

It doesn't recognize *Atoll*.

Like I said, the code thows an error because it cannot complete.
Like my signature line says, "Start debugging"


----------



## MickHH (Aug 24, 2011)

if you look at my original post hans you will see that the script is running inside Atoll which is the host. 
I took the relevent parts of the code out and created a test.vbs with it and ran it as a stand-a-lone script. It worked! Therefore it is a host problem I think.


----------



## Keebellah (Mar 27, 2008)

I could not make out wat Atoll was, and that is what threw the error.
I don't know what you use to write or test your vbs scripts.
I run vbsedit (www.vbsedit.com)
The test version is fully functional except that it displays a wait loop whcih increases on every debug step or execution but works perfectly.


----------

