Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Word 2002 interop error in ASP.NET


Message #1 by shishir_g12@h... on Sun, 12 Jan 2003 07:58:33
Hi All,

Facing wierd problem, through my .NET web application, I am creating word 
documents. While 

creation of the Word documents I am using "Find and Replacement" method 
of Word object, but 

whenever my code runs, it gives me error saying "Stack Overflow 
Exception" or "Object not 

connected to the server" at line (see the code snippet below) where I am 
using Find and 

Replacement method of word object.

I have created Interop assemblies of MS Word (Office XP/2002) using 
VS.NET. I am using 

Office XP with SP1/SP2.

This same application was working earlier in June 2002 that time only SP1 
was there,but in 

its recent release its giving me this problem.

So could any body tell me whether Word interop assemblies (MS Word 
2002/office xp) has some 

problem in exposing all methods/properties of word object.

----------------Code Snippet--------------

wdApp = New Word.ApplicationClass()
wdDoc = New Word.DocumentClass()
wdApp.Application.ScreenUpdating = False
'strdocpath contains path of word document.
wdDoc = wdApp.Documents.Open(strDocPath)

With wdDoc.Content.Find
      .ClearFormatting()
'finding particular text
      .Text = "<<companyname>>"
      .Replacement.ClearFormatting()
'replacing with desired data
      .Replacement.Text=rstDistiData("Distributor")
      .Execute(Replace:=Word.WdReplace.wdReplaceAll, &_ Forward:=True, 

Wrap:=Word.WdFindWrap.wdFindContinue)

End With
------------------End Code Snippet----------------
Word object throws error when it somes on ".Replacement.Text"

Thanks in advance.
--Shishir

  Return to Index