Everything in this little VBS script works right up until I reach the last line of code indicated below. Upon reaching that line the script throws the error “incorrect parameter 80070057.
After spending a great deal of time googling it turns out that the error code means roughly the same thing, incorrect parameter.
'section 15
Set lots = xmlDoc3.selectNodes("ArrayOfLot/Lot")
For Each lot in lots
Dim nl: Set nl = lot.cloneNode(true)
xmlDoc4.documentElement.appendChild nl
Next
xmlDoc4.save xmlDoc4.url 'this code works
'**************************************************************************
'section 16
Set lots = xmlDoc5.selectNodes("ArrayOfLot/Lot")
For Each lot in lots
Dim nll: Set nll = lot.cloneNode(true)
xmlDoc6.documentElement.appendChild nll
Next
xmlDoc6.save xmlDoc6.url 'this does not work - error thrown
It is really frustrating because the .save works just 8 lines above that. Does anyone have any insight to what my problem may be and how I can solve it?
Based on the answer below I am posting the code where all of the document information gets declared:
Dim xmlFilePath6: xmlFilePath6 = "section16.xml"
Dim xmlDoc6: set xmlDoc6 = CreateObject("MSXML2.DomDocument")
xmlDoc6.async = "false"
xmlDoc6.load xmlFilePath6
This actually gets done for 6 different documents, subbing the 6 for one of the other digits 1-8. I’m still puzzled because section16.xml exists and no error is thrown on load.
UPDATE: I adjusted my code so that
xmlDoc6is no longer associated with a file and I have reproduced your error:To reproduce your error, instead of this:
…I initialized
xmlDoc6this way:Hunch: Make sure that
xmlDoc6is associated with a file. If it is not, the value ofxmlDoc6.urlwill be the empty string.ORIGINAL: I have written a complete program to illustrate your use case. However, I am not getting the
incorrect parametererror that you report when attemptingxmlDoc6.save xmlDoc6.url. But perhaps something in my program will stand out that will lead you to a solution.For anyone interested, to run this program, copy the text to a file named say,
demo.vbs, and then run it via:The output to the console should look something like this: