Ok. As I mentioned, you need to translate the macro code into something
using a reference to the selection.
The macro code for your steps produces this output:
Sub Macro4()
ActiveWindow.DeselectAll
ActiveWindow.Select Application.ActiveWindow.Page.Shapes.ItemFromID(3),
visSelect
Application.ActiveWindow.Selection.Copy
Application.ActiveWindow.Page.Paste
Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("Line Properties")
Application.ActiveWindow.Page.Shapes.ItemFromID(4).CellsSRC(visSectionObject,
visRowLine, visLineWeight).FormulaU = "0.25 mm"
Application.ActiveWindow.Page.Shapes.ItemFromID(4).CellsSRC(visSectionObject,
visRowLine, visLinePattern).FormulaU = "9"
Application.EndUndoScope UndoScopeID1, True
Dim UndoScopeID2 As Long
UndoScopeID2 = Application.BeginUndoScope("Fill Properties")
Application.ActiveWindow.Page.Shapes.ItemFromID(4).CellsSRC(visSectionObject,
visRowFill, visFillPattern).FormulaU = "0"
Application.EndUndoScope UndoScopeID2, True
ActiveWindow.DeselectAll
ActiveWindow.Select Application.ActiveWindow.Page.Shapes.ItemFromID(4),
visSelect
Application.ActiveWindow.Selection.Move -0.984252, 0.590551
End Sub
A few obsevations:
a) the long lines will probably be wrapped when you view them in the
newsgroup, so just bear that in mind.
b) each instruction set is enclosed by an UndoScope (which adds them to the
Undo queue). Not required for our purposes here.
c) virtually all actions are based on single instructions with the full
reference back to the Application object which is the main part we need to
translate.
So lets strip out the Undo parts first of all to make things a bit clearer:
Sub Macro4()
ActiveWindow.DeselectAll
ActiveWindow.Select Application.ActiveWindow.Page.Shapes.ItemFromID(3),
visSelect
Application.ActiveWindow.Selection.Copy
Application.ActiveWindow.Page.Paste
Application.ActiveWindow.Page.Shapes.ItemFromID(4).CellsSRC(visSectionObject,
visRowLine, visLineWeight).FormulaU = "0.25 mm"
Application.ActiveWindow.Page.Shapes.ItemFromID(4).CellsSRC(visSectionObject,
visRowLine, visLinePattern).FormulaU = "9"
Application.ActiveWindow.Page.Shapes.ItemFromID(4).CellsSRC(visSectionObject,
visRowFill, visFillPattern).FormulaU = "0"
ActiveWindow.DeselectAll
ActiveWindow.Select Application.ActiveWindow.Page.Shapes.ItemFromID(4),
visSelect
Application.ActiveWindow.Selection.Move -0.984252, 0.590551
End Sub
Next, as we're dealing with two shapes we'll declare two variables for them
and then we can use them as our shape references:
Sub Macro4()
Dim shpOriginal As Shape
Dim shpCopy As Shape
'Assign first shape
Set shpOriginal = ActiveWindow.Selection.PrimaryItem
'Check something was actually selected
If Not shpOriginal Is Nothing Then
'Copy the shape to the clipboard using
'the ...NoTranslate flag to keep its
'original coordinates
shpOriginal.Copy (visCopyPasteNoTranslate)
'Paste and the original shape and assign it to
'the copy shape variable.
ActivePage.Paste (visCopyPasteNoTranslate)
Set shpCopy = ActiveWindow.Selection.PrimaryItem
'Now you have a reference to your new shape
'carry out whatever operations you want to make
With shpCopy
.CellsSRC(visSectionObject, visRowLine, _
visLineWeight).FormulaU = "0.25 mm"
.CellsSRC(visSectionObject, visRowLine, _
visLinePattern).FormulaU = "9"
.CellsSRC(visSectionObject, visRowFill, _
visFillPattern).FormulaU = "0"
'BringToFront isn't really necessary as
'shpCopy was the last shape to be dropped
'on the page, but it's a method of the
'shape object if you're interested
.BringToFront
End With
Else
MsgBox "Please select a shape.", vbOKOnly, "No shape selected"
End If
End Sub
Best regards
John
John Goldsmith
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk