Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub CreateNewWordDoc()
- Dim wrdApp As Word.Application
- Dim wrdDoc As Word.Document
- Dim i As Integer
- Dim arr(12)
- arr(0) = "(249_L), 38,7 %"
- arr(1) = "(248_R), 38,7 %"
- arr(2) = "(249_M), 38,7 "
- arr(3) = "(3560), 38,7 "
- arr(4) = "(3550), 38,7 %"
- arr(5) = "(349_), 38,7 %"
- arr(6) = "(348_), 38,7 %"
- arr(7) = "(451), 38,7 %"
- arr(8) = "(450L), 38,7 "
- arr(9) = "(450R), 38,7 "
- arr(10) = "(151), 38,7 %"
- arr(11) = "(150L), 38,7 %"
- arr(12) = "(150R), 38,7 %"
- Set wrdApp = CreateObject("Word.Application")
- wrdApp.Visible = True
- Set wrdDoc = wrdApp.Documents.Open("E:ShareDrive_Ruehlfull-flexible-MBS-models_reportexample-reportFullFlexibleGearbox - Copy (2).docx")
- wrdDoc.Activate
- wrdApp.Selection.HomeKey unit:=wdStory
- For i = 0 To 12
- With wrdApp.Selection
- With .Find
- .ClearFormatting
- .MatchWildcards = False
- .MatchWholeWord = False
- .Text = arr(i)
- .Execute
- End With
- ' Here is where I need to paste my copied data.
- .InsertAfter "I can just paste this shit"
- .HomeKey unit:=wdStory
- End With
- Next
- End Sub
- Sub CopyToWord()
- 'Copy the range Which you want to paste in a New Word Document
- Cells.Find(What:=arr(0), After:=ActiveCell, LookIn:=xlFormulas _
- , LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
- MatchCase:=False, SearchFormat:=False).Activate
- ActiveCell.Offset(2, 0).Range("A1:g8").Select
- Selection.Copy
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement