Opening a Word 2003 template

Discussion in 'ASP .Net' started by =?Utf-8?B?ZW5haw==?=, Mar 27, 2006.

  1. 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
    --
    enak
     
    =?Utf-8?B?ZW5haw==?=, Mar 27, 2006
    #1
    1. Advertising

  2. 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 hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net



    "enak" <> wrote in message
    news:...
    >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
    > --
    > enak
     
    Steve C. Orr [MVP, MCSD], Mar 27, 2006
    #2
    1. Advertising

  3. 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.
    --
    enak


    "Steve C. Orr [MVP, MCSD]" wrote:

    > 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 hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://SteveOrr.net
    >
    >
    >
    > "enak" <> wrote in message
    > news:...
    > >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
    > > --
    > > enak

    >
    >
    >
     
    =?Utf-8?B?ZW5haw==?=, Mar 27, 2006
    #3
  4. Yes, Crystal Reports could work, although its not my first choice.
    The new VSTO should also work:
    http://msdn.microsoft.com/office/understanding/vsto/

    And these two 3rd party products should work well too:
    http://SteveOrr.net/reviews/AsposeWord.aspx
    http://SteveOrr.net/reviews/OfficeWriter.aspx

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net



    "enak" <> wrote in message
    news:...
    >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.
    > --
    > enak
    >
    >
    > "Steve C. Orr [MVP, MCSD]" wrote:
    >
    >> 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 hope this helps,
    >> Steve C. Orr, MCSD, MVP
    >> http://SteveOrr.net
    >>
    >>
    >>
    >> "enak" <> wrote in message
    >> news:...
    >> >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
    >> > --
    >> > enak

    >>
    >>
    >>
     
    Steve C. Orr [MVP, MCSD], Mar 27, 2006
    #4
  5. I don't have the new VS 2005 installed. I am under a time crunch, too.
    --
    enak


    "Steve C. Orr [MVP, MCSD]" wrote:

    > Yes, Crystal Reports could work, although its not my first choice.
    > The new VSTO should also work:
    > http://msdn.microsoft.com/office/understanding/vsto/
    >
    > And these two 3rd party products should work well too:
    > http://SteveOrr.net/reviews/AsposeWord.aspx
    > http://SteveOrr.net/reviews/OfficeWriter.aspx
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://SteveOrr.net
    >
    >
    >
    > "enak" <> wrote in message
    > news:...
    > >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.
    > > --
    > > enak
    > >
    > >
    > > "Steve C. Orr [MVP, MCSD]" wrote:
    > >
    > >> 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 hope this helps,
    > >> Steve C. Orr, MCSD, MVP
    > >> http://SteveOrr.net
    > >>
    > >>
    > >>
    > >> "enak" <> wrote in message
    > >> news:...
    > >> >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
    > >> > --
    > >> > enak
    > >>
    > >>
    > >>

    >
    >
    >
     
    =?Utf-8?B?ZW5haw==?=, Mar 28, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Charles A. Lackman

    Opening a Word Document

    Charles A. Lackman, Apr 21, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,194
    =?Utf-8?B?VGFyYXM=?=
    Apr 28, 2005
  2. Stephen Witter

    opening a word doc in word not browser

    Stephen Witter, May 18, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    505
    Stephen Witter
    May 18, 2004
  3. =?Utf-8?B?TWFyY28gTWVuZG9uw6dh?=

    Opening Word Template in Internet Explorer

    =?Utf-8?B?TWFyY28gTWVuZG9uw6dh?=, May 12, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    482
    =?Utf-8?B?TWFyY28gTWVuZG9uw6dh?=
    May 12, 2005
  4. Replies:
    1
    Views:
    174
    Evertjan.
    May 30, 2006
  5. fniles
    Replies:
    0
    Views:
    282
    fniles
    Apr 26, 2009
Loading...

Share This Page