Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Andrew Andrew is offline
external usenet poster
 
Posts: 48
Default Server Automation for Word

Hi, I am running into problem when I try to turn my mailmerge automation code
over to the server. My mailmerge code works just fine when being called from
the client workstation (only it is slow like hell and cannot do multiple
documents) I decide to switch the call to the server, which is more powerful
and hopefully can solve the slowness issue. Here's the code.

Public Function CreateWordDocument(ByVal fileName As String, _
ByVal templateName As String, ByVal sourceData As DataSet, _
ByVal workingDirectory As String, ByVal key As Guid) As
MSWord.Document


Dim mergedDoc As MSWord.Document
Dim wrdDoc As MSWord.Document
' Write the Datasource Text File keyDS.txt
Me.FillTable(sourceData, workingDirectory, key)
Me.Application.Visible = True
wrdDoc = Me.AddWordDocument(templateName, False)
wrdDoc.ActiveWindow.Visible = True
wrdDoc.Select()

'Attach DataSource and Perform mail merge if there is any data
If (sourceData.Tables.Count 0) Then
If (sourceData.Tables(0).Rows.Count 0) Then
With wrdDoc.MailMerge

..OpenDataSource(Name:=Me.ConstructFileName(workin gDirectory, key))
End With

Me.PerformMailMerge(wrdDoc)
End If
End If

'Whether a mail merge happen or not, the active document will be the
mergedDoc
mergedDoc = Me.Application.ActiveDocument
mergedDoc.ActiveWindow.Visible = True
mergedDoc.SaveAs(fileName)

'Close the template from documents
If Not (wrdDoc Is mergedDoc) Then
wrdDoc.Close(False)
End If
wrdDoc = Nothing
mergedDoc.ActiveWindow.Visible = True
Me._fileName = mergedDoc.FullName
MSWordApplication.ToggleSaveAs(Me.Application, False)
Return mergedDoc

End Function

As soon as the code run to the line where it actually uses the Word object,
e.g.: wrdDoc.ActiveWindow.Visible = True
It will give the fatal exception error of a null object reference.

Now I have read the kb257757 and tried what says in KB288366 and KB288367 to
configure Office application to run under the interactive user account /
specific user account and to no avail. I need help desperately.
 
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Office licensing on terminal server Brian Microsoft Word Help 2 May 5th 06 08:40 PM
Word slow to open after retiring template server GeorgeJetson Microsoft Word Help 2 April 26th 06 06:25 AM
mail merge documents moved from one server to another server don't Derek Ruesch Mailmerge 0 September 8th 05 06:36 PM
Server Change Affecting Mail Merge Macros Victor Lazlo Mailmerge 1 May 20th 05 02:10 PM
Running document macro from server Intravler New Users 0 March 4th 05 04:33 AM


All times are GMT +1. The time now is 12:44 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"