Opening a Word 2003 template

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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/
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top