Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. Sub CreateNewWordDoc()
  2. Dim wrdApp As Word.Application
  3. Dim wrdDoc As Word.Document
  4. Dim i As Integer
  5. Dim arr(12)
  6.  
  7. arr(0) = "(249_L), 38,7 %"
  8. arr(1) = "(248_R), 38,7 %"
  9. arr(2) = "(249_M), 38,7 "
  10. arr(3) = "(3560), 38,7 "
  11. arr(4) = "(3550), 38,7 %"
  12. arr(5) = "(349_), 38,7 %"
  13. arr(6) = "(348_), 38,7 %"
  14. arr(7) = "(451), 38,7 %"
  15. arr(8) = "(450L), 38,7 "
  16. arr(9) = "(450R), 38,7 "
  17. arr(10) = "(151), 38,7 %"
  18. arr(11) = "(150L), 38,7 %"
  19. arr(12) = "(150R), 38,7 %"
  20. Set wrdApp = CreateObject("Word.Application")
  21. wrdApp.Visible = True
  22.  
  23. Set wrdDoc = wrdApp.Documents.Open("E:ShareDrive_Ruehlfull-flexible-MBS-models_reportexample-reportFullFlexibleGearbox - Copy (2).docx")
  24. wrdDoc.Activate
  25.  
  26. wrdApp.Selection.HomeKey unit:=wdStory
  27.  
  28. For i = 0 To 12
  29. With wrdApp.Selection
  30. With .Find
  31. .ClearFormatting
  32. .MatchWildcards = False
  33. .MatchWholeWord = False
  34. .Text = arr(i)
  35. .Execute
  36. End With
  37. ' Here is where I need to paste my copied data.
  38.  
  39. .InsertAfter "I can just paste this shit"
  40. .HomeKey unit:=wdStory
  41. End With
  42. Next
  43.  
  44.  
  45. End Sub
  46.  
  47. Sub CopyToWord()
  48.  
  49. 'Copy the range Which you want to paste in a New Word Document
  50. Cells.Find(What:=arr(0), After:=ActiveCell, LookIn:=xlFormulas _
  51. , LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
  52. MatchCase:=False, SearchFormat:=False).Activate
  53. ActiveCell.Offset(2, 0).Range("A1:g8").Select
  54. Selection.Copy
  55.  
  56.  
  57. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement