guarding font type is not working.

Started by RobertCburn, February 17, 2009, 07:27:53 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

RobertCburn

I am trying to lock down the font type on the shapesheet for a master shape using =Guard("Arial"). Visio accepts this as a valid formula but then when I drag the shape into a drawing sheet the font that I get is Parchment. When I look at the shapesheet for the object it shows the guard formula. Need some help to get this to work.

vojo

quirky thing about fonts and visio.

Fonts are a number relative to the alphabetical order of all fonts on your laptop.   Two differen laptops showing the same visio diagram with same font number with each laptop have slightly different fonts loaded shows this drawing with different fonts......aka my laptop tomato is your laptops tomato

Visio does not appear to have a nice way to track fonts by some absolute (name or absolute number or or or).   So when visio is completely shut down and you happen to hit doc that has some new fonts in it which get loaded, when visio starts back up, the font at the relative number is used.

Since arial is the default and thus ahead of 90% of the other fonts out there...looks good.
Wingdings font would almost always get messed up since its at the bottom of the list

RobertCburn

Thanks for that bit of info. I think I have worked out a solution using macros to back up my shapesheet. The idea:
1) Macro triggered on load of stencil that will find the font id for "Arial" on given machine.
2) Macro then loops though the shapes in stencil to up date a user.variable with correct font id.
3) Shapes all have =guard(user.variable) as the entry for Character.Font

I will update with code used if this works. If not I am still open for ideas if anyone has them.

vojo

I think all would be curious on how you are managing it in macros...can you post here?

RobertCburn

The Solution is the following formula placed into the Character.Font cell

=GUARD(RUNADDON("FntObjs.Item(""Arial"").ID"))

The RUNADDON function allows for vba code to be placed within a cell.
The reference that I found that taught me this is located here:

http://rozeny.officetutor.org/837

Visio Guy

Hi Robert,

It looks like the font is an index, which might change from document to document. I'm not sure what to say about GUARDing that.

In-line (in-cell) VBA code doesn't work after Visio 2002, I believe, so be careful with that.

Are you really having problems with fonts changing? Could it be that you are sending shapes to users that don't have a particular font installed? It might help to understand the background behind your problem.

Does the text involved change, or is it fixed (like "STOP" on a stop sign)? If it's fixed, maybe you can make a metafile out of it and it might be better preserved. Just an idea...
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Paul Herber

It does seem somewhat odd though that the font changes from Arial to Parchment. If it were a font index problem then surely it would be another font down in the As.

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

RobertCburn

Paul Herber,
   The reason that it was changing to parchment I believe was because of the text "Arial" in a integer field.

Visio Guy,
   I am using Visio 2007 and it does seem to be working very well. Did you mean versions of Visio older then 2002? If that is the case then that is not a concern since my company is at the minimum of 2003. By having the Character.Font call the id it seems to be working. Also the reason to guard it is for creating a design template that others can leverage that has as many of our design standards built into it.

JuneTheSecond

#8
Hi All.

Here is the announcement about "Changes in the RUNADDON Function". ;)
http://msdn.microsoft.com/en-us/library/aa140368(office.10).aspx#vis_runadd_topic2
Best Regards,

Junichi Yoda
http://june.minibird.jp/

Visio Guy

Oh, your RUNADDON is calling a VBA procedure, I see.

I thought you had a string of VBA code in the RUNADDON function, something that isn't allowed anymore. It's hard to know what is going wrong without knowing what the function/object/sub "FntObjs.Item(""Arial"").ID" is really doing.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

RobertCburn

Well nothing is going wrong now, the FntObjs.Item(""Arial"").ID was the answer to the problem. Originally I was trying to use Guard("Arial") and that locking the font but it was not setting it to Arial.

JuneTheSecond

#11
Would you please try to change Arial in your formula
to any other font name for example Century?
Then does the font on the shape change accordingly?
Best Regards,

Junichi Yoda
http://june.minibird.jp/

RobertCburn

JuneTheSecond,
   Thanks for that suggestion. Since Arial is the default font in Visio I would get the right answer this way, not because it works but becuase it returns a 0. So I go back and work out the details of a called macro. As I said earlier I will post the code once working.