Results 1 to 8 of 8

Thread: Starting and quitting Word programmatically

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2002
    Location
    Netherlands
    Posts
    39

    Unhappy Starting and quitting Word programmatically

    To start an instance of Word I use the code

    Code:
     oWord = CreateObject("Word.Application")
                oWord.Visible = True
                oDoc = oWord.Documents.Add("H:\Customer.dot", , , True)
                'oWord.Quit()
    First off, I do not see word starting up, second I don't see word appear at all. However, in the taskmanager it is started, but cannot end the process...

    When I activate the code oWord.Quit() I get an error message before compile stating :
    C:\Inetpub\wwwroot\App\WordInterface.asmx.vb(48): 'Quit' is ambiguous across the inherited interfaces 'Word._Application' and 'Word.ApplicationEvents2_Event'.

    How do I solve these problems?

    I appreciate your help, thanx...

    Dozo

  2. #2
    Addicted Member
    Join Date
    Mar 2001
    Location
    Devon, UK
    Posts
    181
    You need to use early binding. Put a reference to the word object model in your project.

    Dim oApp As New Word.Application()

    oApp.Visible = True

    oApp.Documents.Open("c:\test.doc")

    oApp.Documents.Close()
    Wind and waves resolves all problems.

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2002
    Location
    Netherlands
    Posts
    39

    not able to set visible to true

    Unfortunately I still can't set .Visible tot true.

    The code I use is the following:

    Code:
        Dim oWord As New Word.Application()
        <WebMethod()> Public Function PrintKlant() As String
            oWord.Visible = True
            oWord.Documents.Add("H:\Test.dot", , , True)
            oWord.Application.ActiveDocument.PrintPreview()
            'oWord.Quit()
        End Function
    ALthough I set .Visible to true, it stays False.

    And I stil get the ambiguous warning for the quit statment.

  4. #4
    Addicted Member
    Join Date
    Mar 2001
    Location
    Devon, UK
    Posts
    181
    Unless things have changed drastically you can't execute an exe from a web page, which includes a webmethod. Webservices are purely for generating xml. The code works fine in vb.net but will not work in asp.net. As far as i'm aware what your doing is a no go.
    Wind and waves resolves all problems.

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2002
    Location
    Netherlands
    Posts
    39

    Wink IT does start...

    The Winword.exe does start. I can see this in the Taskmanager... However, the .Visible value stays False. I can't get it set to True.

    My second problem is, that I cannot get it to stop. Everytime I run my asp app, it starts a new instance of Winword.exe, but even in the taskmanager I cannot get it to stop.

    As I said, programmatically the quit statement is still ambiguous and I don't know how to end Winword.exe.. I have tot restart the computer or logout to terminate all existing Winword.exe's.

    So, I do get winword to run, but I can't get it to stop...

    Dozo

  6. #6

    Thread Starter
    Member
    Join Date
    Aug 2002
    Location
    Netherlands
    Posts
    39

    Talking Found part of the problem

    The quit statement seems to have a bug in .NET;

    More on this at microsoft:

    support.microsoft.com/default.aspx?scid=KB;EN-US;Q315981&

    This leaves me with just 1 problem: How do I make Word visible

    Thanx for the help though,

    Dozo

  7. #7
    Addicted Member brookema's Avatar
    Join Date
    Jul 2002
    Location
    Washington DC
    Posts
    161
    Dozo,

    I have the exact same problem. Found a solution yet?

  8. #8

    Thread Starter
    Member
    Join Date
    Aug 2002
    Location
    Netherlands
    Posts
    39

    Red face No

    Haven't found it yet...

    Word does start. However, since I am not able to make it visible does anyone know how to imbed word in an aspx page??

    Maybe that is a solution...

    Dozo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width