Hi All, Requirement Description: - My web application has a requirement of using a few rows of data from a .jsp page, and Merge them into an existing Word template.
I have developed an application using JRun Application/web server and Struts framework. I invoke the winword.exe file from my action class and pass the command line switches as the document filename and the macro name in order to do a word merge process.
The placeholders are in the template Word document. I have built a Macro, which contains the script for invoking the merge process with appropriate data source (.xls) file and saves the merged document in a specific folder in the server. Code for macro is as follows:-
With .DataSource .FirstRecord = wdDefaultFirstRecord .LastRecord = wdDefaultLastRecord End With .Execute Pause:=True End With ActiveDocument.SaveAs FileName:=sPath & "\" & sName & ".doc", FileFormat:= _ wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _ True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _ False, SaveNativePictureFormat:=False, SaveFormsData:=False, _ SaveAsAOCELetter:=False ActiveWindow.Close ActiveDocument.Save ActiveDocument.Close Application.Quit End Sub
The word merge process works fine and I could see the merged document in the concerned place, provided Jrun is running as an application (Admin & Default Server would be invoked from the Start button manually by a user every time the server starts).
Problem: - When the above process is repeated by making JRUN as a Service, the winword.exe hangs; instead of continuing with the request and opening the word document and running the macro for word merge process. I can see winword.exe running in the Task Manager though. We tried capturing the exception but the control never returns back and the process never gets complete.
Is there some conflict happening with the two Applications (JRUN and MS Word 2000) when I start using JRUN as a service? What exactly changes when I change the Jrun from being an Application to exist as a service? Is there a better approach to achieve the above-mentioned objective?
I would greatly appreciate any help in this regard.
Also thanking in advance for all your time and patience in reading this.
Warm Regards, Kamal
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Word Macros doesnt works when using JRun as a Service