I currently developed a word macro to:
1) Find textbox in specific document named "ABC"
2) Copy that textbox
3) Paste it near the cursor
Here's the code:
Code: Select all
Sub CopyTextbox()
Application.ScreenUpdating = False
' Open the source document
Dim SourceDoc As Document
Set SourceDoc = Documents.Open("D:\TextBox.docx")
' Find the textbox named "ABC"
Dim shp As Shape
For Each shp In SourceDoc.Shapes
If shp.Name = "ABC" Then
' Copy the textbox
shp.Select
Selection.Copy
Exit For
End If
Next shp
' Close the source document without saving changes
SourceDoc.Close SaveChanges:=wdDoNotSaveChanges
' Paste the textbox at the cursor position in the active document
Selection.Paste
' Get the pasted shape
Dim pastedShp As Shape
Set pastedShp = ActiveDocument.Shapes(ActiveDocument.Shapes.Count)
' Make the pasted textbox transparent
pastedShp.Fill.Visible = msoFalse
pastedShp.Line.Visible = msoFalse
Application.ScreenUpdating = False
End Sub