Consulting

Results 1 to 3 of 3

Thread: Making one Macro execute in Excel then Word

  1. #1

    Making one Macro execute in Excel then Word

    Hey folks.
    I'm trying to get a macro in excel to run, then take the data the macro selects, put it into a word doc, and then have my word doc run a macro automatically. I used the record macro feature for both macros.

    Excel Macro:

    Range("A3:F3").Select
    Range(Selection,Selection.End(xlDown)).Select
    Selection.Copy
    End Sub
    
    Word Macro:

    Selection.WholeStory
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
    .Text = "^t"
    .Replacement.Text = ", "
    .Forward = True
    .Wrap = wdFindAsk
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    I'm very new to VBA. My job has us open an excel file, copy the range of cells listed in the macro above, then paste them in word and do a find all and replace. Ideally, I'd like to be able to just use one macro in excel to do the entire process. Any help is appreciated! The stuff I've found from google hasn't been helpful so far.
    Last edited by Aussiebear; 11-03-2022 at 05:05 PM. Reason: Added code tags to supplied code

  2. #2
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    Hone your Google-Fu. . .

    Open a Word DOC in Excel.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3

Posting Permissions

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