+ Reply to Thread
Results 1 to 6 of 6

Running Word Macros from Excel

  1. #1
    Registered User
    Join Date
    11-10-2011
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    28

    Running Word Macros from Excel

    Hello,

    I have a set of sub procedures that run in Excel, and the last one opens a certain document in Word. I would like to run and add a few more sub procedures that are already stored in the Word document to the main Excel procedure, as in all Excel macros are run first, then the Word document is open and then the Word macro is run.

    I have tried playing around with the following:


    Please Login or Register  to view this content.

    It goes smoothly as far as opening the Word document but then I get Object Required error

    Is there something that I'm missing in the code?

    Regards,
    shinobi
    Last edited by shinobi; 11-13-2011 at 02:06 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,433

    Re: Running Word Macros from Excel

    You have objWord and WordApp ... I'm guessing they're meant to be the same?

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-02-2011
    Location
    Los Angeles, USA
    MS-Off Ver
    2010 Home Version (doesn't include Access and Outlook )
    Posts
    22

    Re: Running Word Macros from Excel

    Try
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    11-10-2011
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Running Word Macros from Excel

    Hi TMShucks,

    Yes you are correct, thanks for pointing it out. It worked when I changed the name. However, I run into some problems later in Word (string longer than 255 characters - the macro there was supposed to start mail merge). I wanted to have one macro do everything but will have to split it into one Excel and one Word macro. Anyway, thanks for your help.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,433

    Re: Running Word Macros from Excel

    You're welcome. Thanks for the rep.

    Can't you run it all from Excel once you've created the word object?

    Regards

  6. #6
    Registered User
    Join Date
    11-10-2011
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Running Word Macros from Excel

    I googled it and this is what Microsoft says about that:

    "When you use Microsoft Visual Basic for Applications code to perform a mail merge with external data, you may receive the following error message:

    Run-time error '9105'
    String longer than 255 characters

    This problem occurs because Word cannot create a connection string that is longer than 255 characters.

    Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section"

    I think that's exactly my case, I was trying to do mail merge with external data (data from the Excel file that my initial macros run in and then open the Word document)

    Both Excel and Word macros seem to work ok on their own, it is just connecting them together that causes problems.

    Regards,
    shinobi

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1