VB to set image setting

E

Excel User

Hi.

Is it possible to create a routine to import a image from the dialog, that
will:

change the dimensions (x pos, y pos, image width, image height)
Set layer.

Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("Size & Position 2-D")
Application.ActiveWindow.Page.Shapes.ItemFromID(12).CellsSRC(visSectionObject,
visRowXFormOut, visXFormPinX).FormulaU = "421 mm"
Application.EndUndoScope UndoScopeID1, True

Dim UndoScopeID2 As Long
UndoScopeID2 = Application.BeginUndoScope("Size & Position 2-D")
Application.ActiveWindow.Page.Shapes.ItemFromID(12).CellsSRC(visSectionObject,
visRowXFormOut, visXFormPinY).FormulaU = "618 mm"
Application.EndUndoScope UndoScopeID2, True

Dim UndoScopeID3 As Long
UndoScopeID3 = Application.BeginUndoScope("Size & Position 2-D")
Application.ActiveWindow.Page.Shapes.ItemFromID(12).CellsSRC(visSectionObject,
visRowXFormOut, visXFormWidth).FormulaU = "546 mm"
Application.EndUndoScope UndoScopeID3, True

Dim UndoScopeID4 As Long
UndoScopeID4 = Application.BeginUndoScope("Size & Position 2-D")
Application.ActiveWindow.Page.Shapes.ItemFromID(12).CellsSRC(visSectionObject,
visRowXFormOut, visXFormHeight).FormulaU = "1092 mm"
Application.EndUndoScope UndoScopeID4, True

Dim UndoScopeID5 As Long
UndoScopeID5 = Application.BeginUndoScope("Layer")
Application.ActiveWindow.Page.Shapes.ItemFromID(12).CellsSRC(visSectionObject,
visRowLayerMem, visLayerMember).FormulaForceU = """2"""
Application.EndUndoScope UndoScopeID5, True


I created a macro but am unfamiliar to the syntax (I am however familiar
with Excel vba)

I thought it would be more efficient to use a with selection do this.... as
in Excel, is it not possible to use a layer rather than a number?



Thanks,
 
J

John... Visio MVP

Excel User said:
Hi.

Is it possible to create a routine to import a image from the dialog, that
will:

change the dimensions (x pos, y pos, image width, image height)
Set layer.

Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("Size & Position 2-D")

Application.ActiveWindow.Page.Shapes.ItemFromID(12).CellsSRC(visSectionObject,
visRowXFormOut, visXFormPinX).FormulaU = "421 mm"
Application.EndUndoScope UndoScopeID1, True

Dim UndoScopeID2 As Long
UndoScopeID2 = Application.BeginUndoScope("Size & Position 2-D")

Application.ActiveWindow.Page.Shapes.ItemFromID(12).CellsSRC(visSectionObject,
visRowXFormOut, visXFormPinY).FormulaU = "618 mm"
Application.EndUndoScope UndoScopeID2, True

Dim UndoScopeID3 As Long
UndoScopeID3 = Application.BeginUndoScope("Size & Position 2-D")

Application.ActiveWindow.Page.Shapes.ItemFromID(12).CellsSRC(visSectionObject,
visRowXFormOut, visXFormWidth).FormulaU = "546 mm"
Application.EndUndoScope UndoScopeID3, True

Dim UndoScopeID4 As Long
UndoScopeID4 = Application.BeginUndoScope("Size & Position 2-D")

Application.ActiveWindow.Page.Shapes.ItemFromID(12).CellsSRC(visSectionObject,
visRowXFormOut, visXFormHeight).FormulaU = "1092 mm"
Application.EndUndoScope UndoScopeID4, True

Dim UndoScopeID5 As Long
UndoScopeID5 = Application.BeginUndoScope("Layer")

Application.ActiveWindow.Page.Shapes.ItemFromID(12).CellsSRC(visSectionObject,
visRowLayerMem, visLayerMember).FormulaForceU = """2"""
Application.EndUndoScope UndoScopeID5, True


I created a macro but am unfamiliar to the syntax (I am however familiar
with Excel vba)

I thought it would be more efficient to use a with selection do this....
as in Excel, is it not possible to use a layer rather than a number?



Thanks,

Some quick lessons on Visio macro recorded VBA
1) Remove any line referring to UndoScope*
2) Replace Application.ActiveWindow.Page.Shapes.ItemFromID(12) with a
reference to a variable of type Visio.shape
3) ItemFromId is not necessary
4) You also need to find a way to properly reference the picture

dim VisShp as Visio.shape
Set VisShp = Application.ActiveWindow.Page.Shapes(12)

VisShp.CellsSRC(visSectionObject, visRowXFormOut, visXFormPinX).FormulaU =
"421 mm"
VisShp.CellsSRC(visSectionObject, visRowXFormOut, visXFormPinY).FormulaU =
"618 mm"
VisShp.CellsSRC(visSectionObject, visRowXFormOut, visXFormWidth).FormulaU =
"546 mm"
VisShp.CellsSRC(visSectionObject, visRowXFormOut, visXFormHeight).FormulaU =
"1092 mm"
VisShp (12).CellsSRC(visSectionObject, visRowLayerMem,
visLayerMember).FormulaForceU = """2"""

John... Visio MVP
 
E

Excel User

John,

Is it not possible to use a selected object, in Excel use can use the 'with
selection' also is there no way to refer to a specific layer i.e. layer
named 'plan' rather than a number ?

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top