Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Invalid procedure call or argument" on write method 2

Status
Not open for further replies.

poobah252

Programmer
Jul 9, 2001
7
US
Following is the code fragment giving me trouble.

' ***** begin fragment *****

Private Const conOverwriteExistingFile = True ' for CreateTextFile & Copy
Private Const conASCIIformat = 0 ' for OpenAsTextStream

set doc = CreateObject("Msxml2.DOMDocument.3.0") ' "Version dependent rental-threaded" model
doc.validateOnParse = false
doc.async = false
doc.load(CStr(FileName))

set xslDoc = CreateObject("Msxml2.DOMDocument.3.0")
xslDoc.async = false
xslDoc.load(StyleSheetPath)

Set fso = CreateObject("Scripting.FileSystemObject")
Set fHtml = fso.CreateTextFile(xslOutputName, conOverwriteExistingFile, conASCIIformat)
strHtmlTempString = doc.transformNode(xslDoc)

wscript.echo "'Len(strHtmlTempString)' = '" & Len(strHtmlTempString) & "'"
wscript.echo "'strHtmlTempString' = '" & strHtmlTempString & "'"

fHtml.Write strHtmlTempString
fHtml.close
set fHtml = nothing

' ***** end fragment *****

Initially, "fHtml.Write doc.transformNode(xslDoc)" was all one line. Upon receiving the VBScript runtime error "Invalid procedure call or argument" on this line, I split it into two steps & found I am receiving this runtime error on the "write" method.

I added the "wscript.echo" to confirm that I am getting HTML in "strHtmlTempString". I am. It is 7,681 bytes. Only one of dozens of "xml" files I have run through the script gives the run-time error. The successfully-processed files range in size from "1" to "159" kilobytes, so I don't think that string length is an issue.

Anyone have any ideas what else to check?

Thanks, Bill
william.g.starr@cummins.com
812-377-6212
Monday, 8 October 2001, 5:04pm EST
 
Hello, poobah252.

Alter the unicode:
Private Const conASCIIformat = True

See what it gives.

regards - tsuji
 
Thank you, JohnYingling and tsuji, for your helpful replies.

I don't know which character is giving me trouble yet, and it may end up that it does not matter, but creating the output file as Unicode instead of ASCII cures the runtime error.

I sure appreciate your help, after banging my head against the wall on other dead-end ideas all day yesterday.

Regards, Bill
Tuesday, 9 October 2001, 9:36:40am EST
 
Hello again.

Thanks for your feedback. It seems unicode be norm for communicting with msxml parser or other objects. But, am not knowledgeable enough to put a firm delimiter on this. Glad it works out this time.

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top