Results 1 to 3 of 3

Thread: Can an Excel macro launch a Word macro?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    7

    Can an Excel macro launch a Word macro?

    Like the title says:

    Can an Excel macro launch a Word macro?

    And if so, how?

    There it is, short and sweet.

    Anybody got a quick answer? Please? I hope?

    If so, I may be able to ditch another thread I have going, since that one may be irrelevant!

  2. #2
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: Can an Excel macro launch a Word macro?

    As far as I know, no. Not directly. You may be able to fiddle something using a template to run a piece of code on startup.

    The alternative is to automate Word directly from Excel - declare an object as Word.Application and you can access most of the properties as you need. You could then put your macro code within Excel, but execute it on the Word object.


    zaza
    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    7

    Re: Can an Excel macro launch a Word macro?

    Quote Originally Posted by zaza
    As far as I know, no. Not directly. You may be able to fiddle something using a template to run a piece of code on startup.

    The alternative is to automate Word directly from Excel - declare an object as Word.Application and you can access most of the properties as you need. You could then put your macro code within Excel, but execute it on the Word object.


    zaza
    That's what I thought. This has to do with another post I have going. The end goal of both ideas is to use Word mail merge to email but to create a throttle either on the send end of the proccess or on the creation side. I either need to insert a scheduled/delayed delivery time after Word creates the email, OR schedule the mail merge process itself before the email is even created. I a using this post to find a way to do it on the creation side.

    With the other post, I am trying to find a solution on the send side:

    http://www.vbforums.com/showthread.php?t=413188

    I have large databases to link mailmerge to. I have already automated splitting up the databases into separate sheets of appropriate sizes and created separate docs to link to each page. This way each time I get a new database to link to all I need to do is run the split macro on it and replace yesterday's document with today's. Voila! Each Word doc is now linked to the new database. There are 48 docs to run mail merge on daily. They need to be sent every fifteen minutes. It takes nearly twelve hours. As you can imagine, I have things I have to do that keep me away from the computer for more than fifteen minutes.

    Do you know how to schedule that from Excel? I was thinking I needed to find the Word mail merge macro and somehow run that on a scheduled basis but that seems to be not possible. Perhaps what I need to do is what you said. It seems it would be pretty easy if I could find the code for the mail merge and copy it into Excel? Here is the code in Word that I can find:

    Sub Set_up_merge()
    '
    ' Set_up_merge Macro
    ' Macro recorded 6/20/2006 by Me
    '
    ChangeFileOpenDirectory _
    "C:\Documents and Settings\Me\My Documents\Business\PPL\Leads_Folder\"
    Documents.Open FileName:="""First Contact.doc""", ConfirmConversions:= _
    False, ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
    PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
    WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
    ActiveDocument.MailMerge.OpenDataSource Name:= _
    "C:\Documents and Settings\Me\My Documents\Daily_blast_leads\Book1.xls" _
    , ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
    AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
    WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
    Format:=wdOpenFormatAuto, Connection:= _
    "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:\Documents and Settings\Me\My Documents\Daily_blast_leads\Book1.xls;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path=""" _
    , SQLStatement:="SELECT * FROM `Sheet20$`", SQLStatement1:="", SubType:= _
    wdMergeSubTypeAccess
    End Sub

    This code is stored in the Normal.doc so I'm not sure if it's helpful or not. My experience is all in Excel only. I have never worked in Word or Outlook or tried to access their objects from Excel so I'm a babe in the woods with this project! Thanks for the help!
    Last edited by cmerch19602003; Jun 26th, 2006 at 01:13 PM.

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