PDA

View Full Version : Making one Macro execute in Excel then Word



Jimbobo
11-03-2022, 02:30 PM
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.

SamT
11-03-2022, 02:46 PM
Hone your Google-Fu. . .

Open a Word DOC in Excel.

snb
11-03-2022, 03:02 PM
start here: https://www.barnesandnoble.com/s/excel%20vba%20programming%20for%20dummies