Results 1 to 3 of 3
  1. #1
    snax500
    Guest

    Opening Word in Excel

    In Excel2000, I am trying to open a Word2000 document with a macro. The Word document is a mailmerge document. I try this code but the code gets hung up on the Documents.Open line.


    Dim MyWrdApp As Word.Application
    Dim sFile As String
    sFile = "e:testKimclaim01.doc"
    Set MyWrdApp = New Word.Application
    MyWrdApp.Visible = True
    Documents.Open Filename:=sFile, ConfirmConversions:=False, _
    ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
    PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
    WritePasswordTemplate:="", Format:=wdOpenFormatAuto
    Set MyWrdApp = Nothing

    It works on other files but not this one. I guess it has to do with the mailmerge. Any suggestions?

    Thanks

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening Word in Excel

    You have to reference the Word app object 'cause Excel has not idea what a "Document" is.

    Set MyWrdApp = New Word.Application
    With MyWrdApp
    .documents.open Filename:=sfile, bla bla bla
    .
    .

    end with
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening Word in Excel

    You'll probably also need to set a reference to the Word object Library- for me (Office 2K) it's Tools, References, "Microsfot Word 9.0 Object Library".
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

Posting Permissions

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