Opening a Word 2003 template


G

Guest

I need to open a Word template so that I can merge some data from a database
with the document. I am using ASP.NET, VB.NET. I can not even get MS Word to
be visible. I can see that an instance is created in Task Manager.

Here is my code:

Private Sub createReport()
Dim missing As Object = System.Reflection.Missing.Value
Dim file_name As String
Dim file_path As String
Dim file_title As String
Dim word_server As Word.ApplicationClass
Dim sFile As String

sFile = context.Request.PhysicalApplicationPath &
"ScreeningReport.dot"
word_server = New Word.Application
word_server.Visible = True
'''word_server.ChangeFileOpenDirectory(file_path)
word_server.Documents.Open( _
FileName:=sFile, _
ConfirmConversions:=False, _
ReadOnly:=False, _
AddToRecentFiles:=False, _
PasswordDocument:="", _
PasswordTemplate:="", _
Revert:=False, _
WritePasswordDocument:="", _
WritePasswordTemplate:="", _
Format:=Word.WdOpenFormat.wdOpenFormatAuto, Visible:=True)

word_server.Selection.GoTo( _
What:=Word.WdGoToItem.wdGoToBookmark, _
Name:="clientname")
word_server.Selection.TypeText( _
Text:="<Here is the bookmark>")
word_server.Visible = True

End Sub

Why can I not even see the document in the browser?

Also, I have created this using the version of Crystal Reports that comes
with Visual Studio 2003. I have read that it is not re-distributable and is a
trial version. Is this true?

Thanks,
enak
 
Ad

Advertisements

S

Steve C. Orr [MVP, MCSD]

First you need to decide whether you're trying to open Word on the client,
on the server, or both.
Server side COM automation with Office is not recommended:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2

Here are some tips and suggestions for working with Word (and Excel) the
right way:
http://SteveOrr.net/articles/ExcelExport.aspx
http://SteveOrr.net/articles/ExportPanel.aspx
http://SteveOrr.net/reviews/AsposeWord.aspx
http://SteveOrr.net/reviews/OfficeWriter.aspx
http://msdn.microsoft.com/office/understanding/vsto/
 
G

Guest

I don't want to use Word on the server. What I really need is to be able to
have page headers and footers on the documents that are created. I am not
aware of a way to do that by creating the document in HTML and then changing
the context of the header.

This is why I need a better way to do this. I am looking at using Crystal
Reports that comes with VS 2003.
 
Ad

Advertisements


Top