Setting Tab Stops with Automation

M

Mordechai

I'm trying to set tab stops using VBA. Although the code
seems to execute and it corresponds to what I see in the
Visio 2003 Macro Recorder, it's not working. What I get
is an "INVALID TOKEN" in the position cell of the shape
sheet. I've tried every theme and variation I could think
of but nothing seems to work. Here is the code I've been
working with:

.CellsSRC(visSectionTab, 0, visTabStopCount).FormulaU
= "2"
.CellsSRC(visSectionTab, 0, 0 * 3 +
visTabPos).FormulaU = "0.25 in"
.CellsSRC(visSectionTab, 0, 0 * 3 +
visTabAlign).FormulaU = "3"
.CellsSRC(visSectionTab, 0, 0 * 3 + 3).FormulaU
= "0"
.CellsSRC(visSectionTab, 0, 1 * 3 +
visTabPos).FormulaU = "0.75 in"
.CellsSRC(visSectionTab, 0, 1 * 3 +
visTabAlign).FormulaU = "3"
.CellsSRC(visSectionTab, 0, 1 * 3 + 3).FormulaU
= "0"

Any help would be greatly appreciated.
Thanks.
 
P

Paul Anderson [MSFT]

Hi Mordechai

If you're interested, you should check out the Microsoft Office Visio 2003 SDK. Here's the URL

http://www.microsoft.com/downloads/...0BD-B0BB-46E7-936A-B8539898D44D&displaylang=e

It's a free download that contains lots of code samples in its Code Librarian (in VB6, VB .NET, and C# .NET), as well as other tools including a Visio shape-creation environment call ShapeStudio. (End of advertisement.) ;-

This example was modified from the VB6 example called "Text Setting and Formatting". It creates a new, blank document, adds a shape, and sets a single tab stop at 0.75 inches

*********
Sub Main(

Dim sampleDoc As Visio.Documen
Dim sampleShape As Visio.Shap

Set sampleDoc = Visio.Documents.Add(""
Set sampleShape = ActivePage.DrawRectangle(1, 1, 5, 3

' Add a tab that will apply to all text in the shap
Dim intTabRow As Intege
Dim intTabNumber As Intege

intTabRow =
intTabNumber =

' change the tab row type to allow two tab
sampleShape.RowType(VisSectionIndices.visSectionTab,
(intTabRow + VisRowIndices.visRowTab)) = VisRowTags.visTagTab

' set the number of tabs in this row to on
sampleShape.CellsSRC(VisSectionIndices.visSectionTab,
(intTabRow + VisRowIndices.visRowTab),
VisCellIndices.visTabStopCount).ResultIU =

' set the tab valu
sampleShape.CellsSRC(VisSectionIndices.visSectionTab,
(intTabRow + VisRowIndices.visRowTab),
((intTabNumber * 3) + VisCellIndices.visTabPos)).ResultIU = 0.7

End Su
*********
I hope this helps
Pau

This posting is provided "AS IS" with no warranties, and confers no rights.

Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm

----- Mordechai wrote: ----

I'm trying to set tab stops using VBA. Although the code
seems to execute and it corresponds to what I see in the
Visio 2003 Macro Recorder, it's not working. What I get
is an "INVALID TOKEN" in the position cell of the shape
sheet. I've tried every theme and variation I could think
of but nothing seems to work. Here is the code I've been
working with:

.CellsSRC(visSectionTab, 0, visTabStopCount).FormulaU
= "2
.CellsSRC(visSectionTab, 0, 0 * 3 +
visTabPos).FormulaU = "0.25 in
.CellsSRC(visSectionTab, 0, 0 * 3 +
visTabAlign).FormulaU = "3
.CellsSRC(visSectionTab, 0, 0 * 3 + 3).FormulaU
= "0
.CellsSRC(visSectionTab, 0, 1 * 3 +
visTabPos).FormulaU = "0.75 in
.CellsSRC(visSectionTab, 0, 1 * 3 +
visTabAlign).FormulaU = "3
.CellsSRC(visSectionTab, 0, 1 * 3 + 3).FormulaU
= "0

Any help would be greatly appreciated
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