R
rto3rd
FYI: Visio 2003; developing with VBA (however, i'm flexible on the
language.)
I'm working on that age old problem of how to automate the process of
adding pictures to all the objects in an Org Chart. Previous research
seemed to indicate that there wasn't a straightforward way to do this;
i.e. there was no simple function call that could be used to invoke the
same functionality involved in the "Insert Picture" command when doing
this manually.
1) My current solution (which is working pretty well) was to create a
visio macro that allowed me to manipulate import a picture for specific
shape, retrieve the path to a picture, and then import the picture into
the specific OrgChart shape. Afterwards, the macro updates the
necessary ShapeSheet properties on both the OrgChart shape object and
the picture object so that it now behaves the same as if the object had
been created normally by Visio via the manual process. Things are
actually working pretty well.
However, before I spend any more time on this, I wanted to make sure I
wasn't missing a simpler or more obvious solution. Is there a better
or easier way to accomplish this?
2) Other alternate I tried (briefly) was to use the Runaddonwargs
command to invoke the InsertPicture command directly. While this
successfully brought up the InsertPicture dialog, I faced two other
issues. 1) I couldn't figure out how to actually pass the path to the
picture file to the dialog in an automated fashion. 2) Even when I
attempted to supply the path manually, nothing happend. It's possible
i just wasn't calling the RunAddonWargs properly and it wasn't really
running in context of the object I thought it should be. I started
having more luck by manipulating the object to mirror the shapesheets
and so abandoned this idea.
Would this method have worked?
3) Finally, there was one bit of odd behavior I observed while looking
at the shapesheets, that I was hoping someone could explain to me.
If you create a new Org Chart shape (no picture inserted yet), the
"User.Width" cell is set to a formula. Essentially, it just resizes
the base org chart shape (parent) to be 1.5 times it's original size
(depending on the page scale), if all the necessary settings are in
place to enable displaying a picture.
Example: =1.5
in*IF(AND(GetVal(User.DocShowPicture),GetVal(User.ShowPicture),GetVal(User.HasPicture)),1.5,1)*DropOnPageScale
However, after the "Insert Picture" command is performed, the value in
the shape sheet becomes a static value; there's no longer a formula
referenced in the field. It does reflect the new value since the
picture was added. Shape was initially 1.5 in wide and now it's 2.25
inches wide. The cool thing is that when the parent object is updated
to either "Hide Picture" or "Delete Picture", the value continues to
change, but it remains as a static value within the ShapeSheet. To
clarify, the value in the ShapeSheet changes back and forth between
2.25 in and 1.5 in as appropriate for the setting selected; but the
field no longer references the formula, even though it continues to be
used as a basis for this calculation.
Why is that? None of the other fields seem to treat formulas this way.
All the rest seem to remain as formulas (=<some formula specified>).
language.)
I'm working on that age old problem of how to automate the process of
adding pictures to all the objects in an Org Chart. Previous research
seemed to indicate that there wasn't a straightforward way to do this;
i.e. there was no simple function call that could be used to invoke the
same functionality involved in the "Insert Picture" command when doing
this manually.
1) My current solution (which is working pretty well) was to create a
visio macro that allowed me to manipulate import a picture for specific
shape, retrieve the path to a picture, and then import the picture into
the specific OrgChart shape. Afterwards, the macro updates the
necessary ShapeSheet properties on both the OrgChart shape object and
the picture object so that it now behaves the same as if the object had
been created normally by Visio via the manual process. Things are
actually working pretty well.
However, before I spend any more time on this, I wanted to make sure I
wasn't missing a simpler or more obvious solution. Is there a better
or easier way to accomplish this?
2) Other alternate I tried (briefly) was to use the Runaddonwargs
command to invoke the InsertPicture command directly. While this
successfully brought up the InsertPicture dialog, I faced two other
issues. 1) I couldn't figure out how to actually pass the path to the
picture file to the dialog in an automated fashion. 2) Even when I
attempted to supply the path manually, nothing happend. It's possible
i just wasn't calling the RunAddonWargs properly and it wasn't really
running in context of the object I thought it should be. I started
having more luck by manipulating the object to mirror the shapesheets
and so abandoned this idea.
Would this method have worked?
3) Finally, there was one bit of odd behavior I observed while looking
at the shapesheets, that I was hoping someone could explain to me.
If you create a new Org Chart shape (no picture inserted yet), the
"User.Width" cell is set to a formula. Essentially, it just resizes
the base org chart shape (parent) to be 1.5 times it's original size
(depending on the page scale), if all the necessary settings are in
place to enable displaying a picture.
Example: =1.5
in*IF(AND(GetVal(User.DocShowPicture),GetVal(User.ShowPicture),GetVal(User.HasPicture)),1.5,1)*DropOnPageScale
However, after the "Insert Picture" command is performed, the value in
the shape sheet becomes a static value; there's no longer a formula
referenced in the field. It does reflect the new value since the
picture was added. Shape was initially 1.5 in wide and now it's 2.25
inches wide. The cool thing is that when the parent object is updated
to either "Hide Picture" or "Delete Picture", the value continues to
change, but it remains as a static value within the ShapeSheet. To
clarify, the value in the ShapeSheet changes back and forth between
2.25 in and 1.5 in as appropriate for the setting selected; but the
field no longer references the formula, even though it continues to be
used as a basis for this calculation.
Why is that? None of the other fields seem to treat formulas this way.
All the rest seem to remain as formulas (=<some formula specified>).