Visio 2000 VBA General Questions

D

David Hawkins

Hello,

I'm new to Visio VBA development and miss the macro recorder feature of
Excel. Looking for help with a few Visio.Shape parameters for Visio 2000
Professional.

Dim rectObj As Visio.Shape
Set rectObj = ActivePage.DrawRectangle(10, 10, 12, 12)
rectObj.Text = "testing..." + vbTab + "1.2.3" + vbTab + "testing..."
rectObj.Cells("Char.Size[1]").Formula = "= 8 pt."
rectObj.Cells("LineColor") = 1
rectObj.Cells("Fillforegnd") = 5

How do I
1. Set the background to transparent (FillForegndTrans crashes) can't see
ojbect below.
2. Set the font to Bold
3. Set tabStops at 0.5" and 1.5"
4. Center and Left Align text
5. Set the line width (or line weight)
6. Set the line patter (dashed or solid)

Thank you,
David
 
J

John Marshall, MVP

The macro recorder was added to Visio 2003

Hope fully I have put the right comments with the right code.

Sub Macro1()

'transparency
ActivePage.Shapes.ItemFromID(1).CellsSRC(visSectionObject, visRowFill,
visFillForegndTrans).FormulaU = "55%"
ActivePage.Shapes.ItemFromID(1).CellsSRC(visSectionObject, visRowFill,
visFillBkgndTrans).FormulaU = "55%"

' bold
Dim vsoCharacters2 As Visio.Characters
Set vsoCharacters2 = ActivePage.Shapes.ItemFromID(1).Characters
vsoCharacters2.Begin = 0
vsoCharacters2.End = 8
vsoCharacters2.CharProps(visCharacterStyle) = 17#

'tabs
ActivePage.Shapes.ItemFromID(1).CellsSRC(visSectionTab, 0,
visTabStopCount).FormulaU = "2"
ActivePage.Shapes.ItemFromID(1).CellsSRC(visSectionTab, 0,
visTabPos).FormulaU = "0.5 in"
ActivePage.Shapes.ItemFromID(1).CellsSRC(visSectionTab, 0,
visTabAlign).FormulaU = "0"
ActivePage.Shapes.ItemFromID(1).CellsSRC(visSectionTab, 0, 4).FormulaU =
"1.5 in"


Dim vsoCharacters7 As Visio.Characters
Set vsoCharacters7 = ActivePage.Shapes.ItemFromID(1).Characters
vsoCharacters7.Begin = 0
vsoCharacters7.End = 8
' align left
vsoCharacters7.ParaProps(visHorzAlign) = 0#
'align centre
vsoCharacters7.ParaProps(visHorzAlign) = 1#
'align right
vsoCharacters7.ParaProps(visHorzAlign) = 2#

'line weight
ActivePage.Shapes.ItemFromID(1).CellsSRC(visSectionObject, visRowLine,
visLineWeight).FormulaU = "2.16 pt"
'line pattern
ActivePage.Shapes.ItemFromID(1).CellsSRC(visSectionObject, visRowLine,
visLinePattern).FormulaU = "3"

End Sub

John... Visio MVP

Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
Need VBA examples? http://www.mvps.org/visio/VBA.htm
Common Visio Questions http://www.mvps.org/visio/common_questions.htm
 
D

David Hawkins

Hi John,

Thank you for you response. I am getting an error on the first line though.
Compile Error: Variable not defined. visFillForegndTrans was highlighted in
VBE. Same thing on visFillBkgndTrans.

The rest of the code ran but didn't affect my current shape object. I
think
it updated an existing shape (id = 1). Since I was just building objects
sequentially as I needed them I haven't used the ActivePage.Shapes.Item...
methods. I'll experiment with that today.

Would the online documentation for Visio 2003 be the same for this part
of the code? I can't seem to find very much online for Visio 2000.

Thanks,
David
 
J

John Marshall, MVP

D

David Hawkins

(sJohn,

So if I understand you correctly the UI functionality of selecting a box
(shape) and
setting the Fill Color to "No Fill" is not supported programatically in
Visio 2000?
That would be a bummer.

David
 
D

David Hawkins

Thank you John. This is exactly what I wanted. Sorry for asking for
transparancy
when I meant No Fill.

David
 
D

David Hawkins

John,

A couple of things. I replaced ActivePage.Shapes.ItemFromID(1) with
my original rectObject. This causes the method to work on the current
object which is what I wanted.

Everything is working except the tab stops. The code runs but when I
go back into the drawing window, click on the object, and selected
Format -> Text... I get the error:

! An error(1) occurred during teh action Text Properties
Unexpected end of file
[Ok]

I commneted out each line trying to figure out which one was causing
the problem but even the first line does it. Any ideas how to fix this?

Secondly, I would like to use fill color on some rectangle objects. I
am able to se the fill color using .Cells("Fillforegnd") = 1. I've tried
quite a few values but can't really figure out how to set it to any
particular color. I tried RGB(100, 128, 100), and sevaral variations on
this but couldn't get the same color as in Color Chooser.

Thank you,
David
 
D

David Hawkins

John,

Cancel the color request. By process of elimination I found a few colors
that
look good on the screen and print in black/white okay. The RGB function would
be nice. The built-in Custom Color chooser has Hue, Saturation, and Luminance
parameters which the RGB obviously does not.

David
 

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