You are on page 1of 9

Generate Visio Flow Chart from IBM Maximo

Generate Visio Flow Chart from IBM


Maximo
Generate Visio Flow Chart from IBM Maximo

Content
1. LIST OF TOOLS AND APPLICATION USED 3

2. EXTERNAL SITE REFERENCE 3

3. QUERY 4

4. MACRO 5

5. STEPS 8

6. NOTE: 9
Generate Visio Flow Chart from IBM Maximo

1. List of Tools and Application Used

 IBM Maximo 7.6.0.2


 Oracle Database
 Microsoft Excel 2016
 Microsoft Vision 2013

2. External Site Reference

Original macro downloaded from following site, Did some modification to meet specific
requirement.

https://www.mrexcel.com/forum/excel-questions/651691-create-visio-document-excel-
using-vba.html
Generate Visio Flow Chart from IBM Maximo

3. Query
select
wfnode.nodeid "Step",
case
when wfnode.nodetype = 'START' then 'Start/End'
when wfnode.nodetype = 'CONDITION' then 'Decision'
when wfnode.nodetype = 'TASK' then 'Process'
when wfnode.nodetype = 'SUBPROCESS' then 'Subprocess'
when wfnode.nodetype = 'INPUT' then 'Data'
when wfnode.nodetype = 'STOP' then 'Start/End'
when wfnode.nodetype = 'INTERACTION' then 'Frame' end "Node",
wfnode.title "Node Title",
case when wfaction.ispositive = 1 then wfaction.membernodeid else null end "Connect 1",
case
when "Connect 2" is not null then 'Yes' else null end "Connect 1 Text",
"Connect 2",
"Connect 2 Text",
wfcondition.condition,
wfaction.action,
wfaction.instruction,
wfaction.condition wfactioncond
from wfnode left join wfaction
on wfaction.processname = wfnode.processname and wfaction.processrev = wfnode.processrev and
wfaction.ownernodeid = wfnode.nodeid
left join wfcondition on wfcondition.processname= wfnode.processname and
wfcondition.processrev=wfnode.processrev and wfcondition.nodeid=wfnode.nodeid
left join (select wfaction.membernodeid "Connect 2",wfaction.ownernodeid,wfnode.nodetype,'No' "Connect 2
Text"
from wfnode inner join wfaction
on wfaction.processname = wfnode.processname and wfaction.processrev = wfnode.processrev
and wfaction.ownernodeid = wfnode.nodeid
left join wfcondition on wfcondition.processname= wfnode.processname and
wfcondition.processrev=wfnode.processrev and wfcondition.nodeid=wfnode.nodeid
where wfnode.processname = 'CHANGE'
and wfnode.processrev = 1 and wfaction.ispositive = 0) a on a.ownernodeid =
wfaction.ownernodeid and a.nodetype = wfnode.nodetype
where wfnode.processname = 'CHANGE'
and wfnode.processrev = 1 and (wfaction.ispositive = 1 or wfaction.ispositive is null)
group by
wfaction.ownernodeid,wfnode.nodeid,wfnode.nodetype,wfaction.ispositive,wfaction.membernodeid,wfnode.titl
e,"Connect 2","Connect 2 Text",wfcondition.condition,
wfcondition.condition,wfaction.action,wfaction.instruction,wfaction.condition
order by wfnode.nodeid
Generate Visio Flow Chart from IBM Maximo

4. Macro
Option Explicit

Dim AppVisio As Object

Sub CreateLinkedVisioBoxesForColumn1Data()

'For each cell in column A starting in A1, create a rectangle in Visio and connect to the next box
Dim lLastRow As Long
Dim aryRowData() As Variant

lLastRow = Cells(Rows.Count, 1).End(xlUp).Row


aryRowData = Range(Cells(1, 1), Cells(lLastRow, 1)).Value
DropStringOfBoxes aryRowData

MsgBox "Complete"

End Sub

Sub DropStringOfBoxes(aryRange() As Variant)


'Given an array, create a grid of vision boxes connected in order

'Dim aryRange() As Variant '(1,1)...(1,N)


Dim aryContents() As Variant '0...N
Dim lAryIndex As Long
Dim lAryRangeIndex As Long
Dim lShapeIndex As Long
Dim sngX As Single
Dim sngY As Single
Dim sngDeltaX As Single
Dim sngDeltaY As Single
Dim lLastDropIndex As Long

Dim lCurrDropIndex As Long


Dim bAllInSameVisio As Boolean
Dim vsoConnectorShape As Visio.Shape

Dim shp1 As Object


Dim shp2 As Object
Dim shp3 As Object

Dim dummy As Integer

bAllInSameVisio = True

'If using input parameter array


For lAryIndex = LBound(aryRange, 1) To UBound(aryRange, 1)
ReDim Preserve aryContents(0 To lAryRangeIndex)
aryContents(lAryRangeIndex) = aryRange(lAryIndex, 1)
lAryRangeIndex = lAryRangeIndex + 1
Next

sngDeltaX = 2.5
sngDeltaY = 2
sngX = 1.25
sngY = 13.5
If bAllInSameVisio Then
'Is Visio already running
On Error Resume Next
' Check whether PowerPoint is running
Set AppVisio = GetObject(, "Visio.Application")
Generate Visio Flow Chart from IBM Maximo

If AppVisio Is Nothing Then


' Visio is not running, create new instance
Set AppVisio = CreateObject("visio.Application")
AppVisio.Visible = True
End If
Else
'Open new copy of Visio
Set AppVisio = CreateObject("visio.Application")
AppVisio.Visible = True
End If

'Add New Drawing


AppVisio.Documents.AddEx "", visMSDefault, 0 'Open Blank Visio Document
AppVisio.Documents.OpenEx "PATH\Documents\My Shapes\Favorites.vssx", visOpenRO + visOpenDocked 'Add
Basic Stencil

Set vsoConnectorShape = AppVisio.ActivePage.Shapes("line2")

For lShapeIndex = LBound(aryContents) + 1 To UBound(aryContents)


'Calculate Position

sngY = sngY - sngDeltaY


If sngY < 1.5 Then
sngY = 10.5
sngX = sngX + sngDeltaX
End If

'Set stencil
AppVisio.ActiveWindow.Page.Drop AppVisio.Documents.Item("Favorites.vssx").Masters.ItemU(Cells(lShapeIndex,
2).Value), sngX, sngY
'Set primary id of shapes
'AppVisio.ActiveWindow.Selection.PrimaryItem.ID = Cells(lShapeIndex, 1).Value

lCurrDropIndex = AppVisio.ActiveWindow.Selection.PrimaryItem.ID
SetShapeText lCurrDropIndex, CStr(Cells(lShapeIndex, 3).Value)

Next

For lShapeIndex = 1 To lCurrDropIndex

Set shp1 = AppVisio.ActivePage.Shapes.ItemFromID(Cells(lShapeIndex, 1).Value)


Set shp2 = AppVisio.ActivePage.Shapes.ItemFromID(Shape(Cells(lShapeIndex, 4).Value))

If IsEmpty(Cells(lShapeIndex, 4)) = False Then


dummy = DoAutoConnect(shp1, shp2, 0, CStr(Cells(lShapeIndex, 5).Value))
End If
Set shp3 = AppVisio.ActivePage.Shapes.ItemFromID(Shape(Cells(lShapeIndex, 6).Value))
If IsEmpty(Cells(lShapeIndex, 6)) = False Then
dummy = DoAutoConnect(shp1, shp3, 4, CStr(Cells(lShapeIndex, 7).Value))
End If
Next
Set AppVisio = Nothing
End Sub

Function Shape(LookForVal As Integer) As Integer

Dim Row As Integer


Row = 2
Do
If CInt(Cells(Row, 1).Value) = LookForVal Then Exit Do
Row = Row + 1
Loop
Generate Visio Flow Chart from IBM Maximo

Shape = Row - 1
End Function

Sub SetShapeText(lShapeID As Long, sEntry As String)


'Add Text to Shape
Dim vsoCharacters1 As Object

Set vsoCharacters1 = AppVisio.ActiveWindow.Page.Shapes.ItemFromID(lShapeID).Characters


vsoCharacters1.Begin = 0
vsoCharacters1.End = 0
vsoCharacters1.Text = sEntry
AppVisio.ActiveWindow.Page.Shapes.ItemFromID(lShapeID).CellsSRC(2, 0, 5).FormulaU = "36 pt"
'visSectionCharacter, 0, visCharacterSize
Set vsoCharacters1 = Nothing
End Sub

Function DoAutoConnect(fromShape As Object, toShape As Object, dir As Integer, ctext As String) As Integer

Dim con1 As Object


Dim con2 As Object

fromShape.AutoConnect toShape, dir

For Each con1 In fromShape.FromConnects


For Each con2 In con1.FromSheet.Connects
If con2.ToSheet.ID = toShape.ID Then
con2.FromSheet.Text = ctext
con2.FromSheet.Cells("EndArrow").Formula = "04"
End If
Next
Next
DoAutoConnect = 1
End Function
Generate Visio Flow Chart from IBM Maximo

5. Steps
1. Use attached query to extract data from workflow objects and arrange data with following
required columns as below format please make sure to add last blank row manually.

Name Flow chart symbol Text Connects 1 Connect 1 Text Connects 2 Connect 2 Text
1 Start/End START 1 9
2 Start/End STOP 2
3 Decision MINOR? 4 Yes 5 No
4 Frame NOAPPROVE 9
5 Decision SIGNIF? 6 Yes 13 No
6 Process MANAGER 7 Yes 12 No
7 Process AREAS 8 Yes 12 No
8 Process APPROVED 2
9 Decision VALID? 3 Yes 10 No
10 Frame INVALID 9
12 Process REJECTED 3 Yes 2 No
13 Process MANAGER1 15 Yes 12 No
14 Process AREAS 8 Yes 12 No
15 Process CAB 14 Yes 12 No
16

2. Run attached macro, which will create a visio diagram with flowchart, which you can improve
with auto spacing and available design format in visio.

MANAGER No

START 1 Yes

Yes AREAS No

Yes No REJECTED

APPROVED AREAS

Yes

Yes

STOP 2 Yes
No No
MINOR? No SIGNIF? No MANAGER1

CAB

Yes
Yes VALID?

NOAPPROVE
INVALID
Generate Visio Flow Chart from IBM Maximo

6. Note:
 Add all required shapes to visio favorite
 Search “PATH” word in attached Macro file and replace it with actual path of
Favorite.vssx, usually you will find it under C:\Users\*****\Documents\My Shapes\
Favorites.vssx.
 Update attached query with process name and its version.

You might also like