Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visio VBA-Change Position Type

Status
Not open for further replies.

drmerby3737

Programmer
Apr 21, 2010
3
US
Hello,

I have generated an organization chart in Visio 2003 using the wizard with an Excel sheet. I am trying to change all the position types to "Position" so that all the shapes look identical. Can this be done through VBA coding?

Thanks
 


Hi,

I no nothing about the Visio object model. However, I do know how to use the Object Browser and the Watch Window in the VB Editor to "discover" what the available properties are for a particular object. You'll have to do some patient exploring.

faq707-4594

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks for respoding so quickly! I have been already looked at the suggestions you have made before posting this question. There does not seem to be any property to change this that I can find. I even tried the macro recorder and changing the shape manually. It does not record anything. Any other suggestions would be greatly appreciated!

Thanks
 



Is the organization chart in Visio or in Excel?

If in an Excel sheet...
Code:
dim shp as shape

for each shp in activesheet.shapes
   with shp
      debug.print .name, .type, .topleftcell.address, .top, .left
   end with
next


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks for your help! I have found a solution.

Sub Test()

OrgChart_ChangePositionType 1, 2

End Sub


Sub OrgChart_ChangePositionType(intShapeNumber As Integer, intPositionType As Integer)
' Accesses User-defined Cells for the shape
' Org Chart Shapes Position Types:
' Executive = 0
' Manager = 1
' Position = 2
' Consultant = 3
' Vacancy = 4
' Assistanct = 5
' Staff = 6

Dim vsoPage As Visio.Page
Dim vsoShape As Visio.Shape
Dim vsoCell As Visio.Cell
Dim intCounter As Integer

Set vsoPage = ActivePage

'If there isn't an active page, set vsoPage
'to the first page of the active document.
If vsoPage Is Nothing Then
Set vsoPage = ActiveDocument.Pages(1)
End If

'Set the vsoShape to the desired shape (1 thru Visio.ActivePage.Shapes.Count)
'vsoPage.Shapes(1) is the first or topmost org chart shape
Set vsoShape = vsoPage.Shapes(intShapeNumber)

'Set vsoCell to the desired user-defined cell and set its formula.
Set vsoCell = vsoShape.Cells("User.ShapeType")
vsoCell.Formula = intPositionType

End Sub

It works great!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top