Changing Visio ActiveX properties at run time

M

Mr

Hi all,

I'm using Visio ActiveX on Windows Form application.

I've several properties questions:
1. How do I set the upper left corner of the document as the axis
origin (0,0)
2. How do I change the document Measurement units to "Points"
(Manualy: Tools menu > Options > Units tab > Change button >
Page Properties tab > Measurement Units = "Points"
3. How do I change the Drawing Scale to Custom scale "1 pt = 1 pt"
and the Page Size to "4096 pt * 4096 pt"
(Manualy: Tools menu > Options > Units tab > Change button >
Drawing Scale tab > Custom scale radio button > Page size = "4096 pt *
4096 pt"

I'm looking for the way how to change them programmatically (Using
Visual Basic / C++)

Any help is welcome

Thanks,
Roee
 
C

Chris Roth [MVP]

Hi Roee,

Here's the answers. I simply used the Visio Macro Recorder to get the code
samples. You don't need the UndoScope stuff, but it's not a bad idea to have
it in your code.

1. Can't change the origin as far as drawing programmatically goes. You can
change the origin for the ruler, which is really a UI-thing. You still have
a standard, Cartesian-coordinate system, with 0 at the top -- the page will
then be in -Y territory. You change it like this:

Sub ChangeRulerOrigin
Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("Ruler & Grid")
Dim vsoShape1 As Shape
Set vsoShape1 = Application.ActiveWindow.Page.PageSheet
vsoShape1.CellsSRC(visSectionObject, visRowRulerGrid,
visXRulerOrigin).FormulaU = "3 mm"
vsoShape1.CellsSRC(visSectionObject, visRowRulerGrid,
visYRulerOrigin).FormulaU = "298 mm"
vsoShape1.CellsSRC(visSectionObject, visRowRulerGrid,
visXGridOrigin).FormulaU = "3 mm"
vsoShape1.CellsSRC(visSectionObject, visRowRulerGrid,
visYGridOrigin).FormulaU = "298 mm"
Application.EndUndoScope UndoScopeID1, True
End Sub

2. Change page units to Points:

Sub ChangePageToPoints()
Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("Page Setup")
Application.ActivePage.Background = False
Application.ActivePage.BackPage = ""
Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPage,
visPageScale).FormulaU = "1 pt"
Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPage,
visPageDrawingScale).FormulaU = "1 pt"
Application.EndUndoScope UndoScopeID1, True
End Sub

3. You don't need to change the scale to 1pt = 1pt if you change the page
units to Point! It's already done for you!


--
Hope this helps,

Chris Roth
Visio MVP

www.wanderkind.com/visio
 

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