Problems with macro's

S

seppe

Hi

I have a problem with running a macro in a Word doc.

This is the situation:
I have a Word doc which uses an Add in with a macro. This Word doc acts
like a template, and the Add in provides a function to generate a web
page, based on the value in a comment in this Word doc.

So since I want to generate lots of webpages based on information from
a CSV file, I use a WSH script which opens this Word doc and iterates
over the CSV file. In each iteration I change the value in this Word
comment and run the macro to generate my precious web pages.

Most of the time, it goes great ... but in some situations the Macro
fails for some reason, and displays an error window with "Show error
report" and "Yes" and "No" buttons. It seems that this macro is using
XMLGen or something, which causes the error.

Since I want to run this WSH script in batch mode .. this error window
is a problem because in requires user interaction (by pressing on "Yes"
or "No").

So my question is:
How can I avoid this user interaction?


I don't know it's necessary to show some code, but I'll do anyway. This
is the function in my WSH file that does the generation. As you can
see, it calls the "mGenerateWebpage" macro in the Word doc. This
"mGenerateWebpage" macro is the one who sometimes fails and shows the
error window. When this error window pops up, the macro is still
running (because I have to press "Yes" or "No" first), so I haven't
been able to track it or something. Maybe you guys can help me?

Anyway, here is the code:

Sub generateFromArray(anArray,prefix)
Dim objPara,objComment,strRemarks,theFile

For i = 0 to Ubound(anArray)
'On error resume next
curArray = anArray(i)
useCase = ""
package = ""
for j = 0 to ubound(curArray)
if j = 0 then
package = curArray(j)
elseif j <> ubound(curArray) then
package = package & "::" & curArray(j)
else
usecase = curArray(j)
end if
next

sodaComment = "C:UseCase:Rose:UseCase:Model.Path=^S" &
transform(model) & ",Package.Name=^S" & transform(package) &
",UseCase.Name=^S" & transform(usecase)

wordApp.ActiveDocument.Comments(1).Range.Text = sodaComment
wordApp.ActiveDocument.Save
wordApp.Visible = False

if verboseMode then
WScript.Echo " " & package & "::" & usecase
end if

wordApp.run("mGenerateWebpage")

'Create folder for use case
newFolderPath = outputPath & prefix & "\" & useCase
FSO.CreateFolder newFolderPath

'Copy generated files from the root folder to the Use Case
Folder
newFilePath = newFolderPath & "\" & useCase & ".htm"
FSO.CopyFile templateOutputFilePath,newFilePath
FSO.CopyFolder templateFilesPath,newFolderPath & "\" &
templateFilesFolder

'Clean up
cleanUpEachTime()
Next
End Sub




Thanks for helping and sorry for my bad english. I'm not a native
English speaker :)


Greetings

Sebastian Van Sande
 

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