Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / November 2003

Tip: Looking for answers? Try searching our database.

Merge stops working when I use the App server as a Service

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nitin - 01 Nov 2003 17:49 GMT
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.

Runtime rt = Runtime.getRuntime ();
String[] callAndArgs =
strWordExePath,strWordTempName,"/mMacroName"};
Process child = rt.exec(callAndArgs);
child.waitFor();

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:-

Sub AutoExec()
Dim sName As String
   
   Selection.HomeKey Unit:=wdStory
   sName = ActiveDocument.Name
   sName = Left(sName, Len(sName) - 9)
   sPath = ActiveDocument.Path
   
   ActiveDocument.MailMerge.OpenDataSource Name:= _
       sPath & "\" & sName & ".xls" _
       , ConfirmConversions:=False, ReadOnly:=False,
LinkToSource:=True, _
       AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", _
       WritePasswordDocument:="",
WritePasswordTemplate:="", Revert:=False, _
       Format:=wdOpenFormatAuto, Connection:="Entire
Spreadsheet", SQLStatement _
       :="", SQLStatement1:=""
   With ActiveDocument.MailMerge
       .Destination = wdSendToNewDocument
       .MailAsAttachment = False
       .MailAddressFieldName = ""
       .MailSubject = ""
       .SuppressBlankLines = True
       
       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,
Nitin
Peter Jamieson - 02 Nov 2003 11:19 GMT
There is probably a security-related problem as the chances are that your
service is running under a different user name. However, that's about all I
know about it - you'll robably find more useful info at

PRB: Error 800A175D - Could Not Open Macro Storage
http://support.microsoft.com/default.aspx?scid=kb;en-us;224338

and the general article referenced there:
INFO: Considerations for Server-Side Automation of Office
http://support.microsoft.com/default.aspx?kbid=257757:

--
Peter Jamieson
MS Word MVP

> Requirement Description: - My web application has a
> requirement of using a few rows of data from a .jsp page,
[quoted text clipped - 92 lines]
> Warm Regards,
> Nitin
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.