S
Steve
I'm storing a two-cell table in an AutoText entry. VBA inserts the table
from AutoText, moves the cursor up two lines, and pastes a graphic into Cell
1 from the clipboard. This works fine if step slowly through the code. When
I run the code, the PasteSpecial gets executed BEFORE the AutoText insertion
is completed and the cursor hasn't moved up two lines. As a result, the
graphic is pasted below the table. How do I make sure that the
AutoTextEntries().Insert is completed successfully before moving to the next
line of code?
Steve
Sub SetTableDims()
Dim oHeight As Single
Dim oWidth As Single
NormalTemplate.AutoTextEntries("Insert Figure").Insert _
Where:=Selection.Range
Selection.MoveUp Unit:=wdLine, Count:=2
Selection.PasteSpecial Link:=False, _
DataType:=wdPasteDeviceIndependentBitmap, _
Placement:=wdInLine, _
DisplayAsIcon:=False
oHeight = Selection.Tables(1).Cell(1, 1).Range.InlineShapes(1).Height
oWidth = Selection.Tables(1).Cell(1, 1).Range.InlineShapes(1).Width
Selection.Tables(1).Cell(1, 1).Height = oHeight
Selection.Tables(1).Columns(1).Width = oWidth
End Sub
from AutoText, moves the cursor up two lines, and pastes a graphic into Cell
1 from the clipboard. This works fine if step slowly through the code. When
I run the code, the PasteSpecial gets executed BEFORE the AutoText insertion
is completed and the cursor hasn't moved up two lines. As a result, the
graphic is pasted below the table. How do I make sure that the
AutoTextEntries().Insert is completed successfully before moving to the next
line of code?
Steve
Sub SetTableDims()
Dim oHeight As Single
Dim oWidth As Single
NormalTemplate.AutoTextEntries("Insert Figure").Insert _
Where:=Selection.Range
Selection.MoveUp Unit:=wdLine, Count:=2
Selection.PasteSpecial Link:=False, _
DataType:=wdPasteDeviceIndependentBitmap, _
Placement:=wdInLine, _
DisplayAsIcon:=False
oHeight = Selection.Tables(1).Cell(1, 1).Range.InlineShapes(1).Height
oWidth = Selection.Tables(1).Cell(1, 1).Range.InlineShapes(1).Width
Selection.Tables(1).Cell(1, 1).Height = oHeight
Selection.Tables(1).Columns(1).Width = oWidth
End Sub