Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. Private Sub CommandButton2_Click()
  2.  
  3. ' Copy table from source document and add to table in target document
  4.  
  5. Dim oTarDoc As Document, oSourceDoc As Document
  6. Dim oTable As Table
  7. Dim oNewRow As Row
  8.  
  9. Set oSourceDoc = Documents.Open("H:Test DocumentsTables.docx")
  10. Set oTarDoc = Documents.Open("H:Test DocumentsProduct.docm")
  11.  
  12. Application.ScreenUpdating = False
  13.  
  14. oTarDoc.Activate
  15. Set oTable = oTarDoc.Tables(2)
  16. Set oNewRow = oTable.Rows(oTable.Rows.Count - 3)
  17.  
  18. oSourceDoc.Activate
  19. Selection.GoTo What:=wdGoToBookmark, Name:="A" & InputBox("119f, 979, 981a...", "Enter Number and Letter as Shown")
  20. With oSourceDoc.Bookmarks
  21. .DefaultSorting = wdSortByName
  22. .ShowHidden = False
  23. End With
  24. Selection.Tables(1).Select
  25. Selection.Copy
  26.  
  27. oTarDoc.Activate
  28. oNewRow.Select
  29. Selection.Paste
  30. Application.ScreenUpdating = True End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement