-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathForm1.frm
1095 lines (976 loc) · 38 KB
/
Form1.frm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
VERSION 5.00
Begin VB.Form Form1
BackColor = &H8000000D&
BorderStyle = 1 'Fixed Single
Caption = "visio2python"
ClientHeight = 8505
ClientLeft = 45
ClientTop = 435
ClientWidth = 15255
FillStyle = 2 'Horizontal Line
BeginProperty Font
Name = "Arial"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "Form1.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 8505
ScaleWidth = 15255
Begin VB.ListBox Output
Appearance = 0 'Flat
BeginProperty Font
Name = "Courier New"
Size = 12
Charset = 204
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 5430
Left = 120
TabIndex = 10
Top = 3000
Width = 15015
End
Begin VB.Frame Frame4
Appearance = 0 'Flat
BackColor = &H8000000D&
BorderStyle = 0 'None
Caption = "Step 3"
BeginProperty Font
Name = "Arial"
Size = 9.75
Charset = 204
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000E&
Height = 2895
Left = 10200
TabIndex = 13
Top = 0
Width = 4935
Begin VB.CommandButton Command6
Appearance = 0 'Flat
BackColor = &H80000014&
Caption = "Add"
Height = 340
Left = 4200
Style = 1 'Graphical
TabIndex = 16
Top = 1560
Width = 615
End
Begin VB.ComboBox Combo1
Height = 330
ItemData = "Form1.frx":33E2
Left = 120
List = "Form1.frx":33E4
TabIndex = 15
Text = "Combo1"
Top = 1560
Width = 3975
End
Begin VB.CheckBox Check3
Appearance = 0 'Flat
BackColor = &H8000000D&
Caption = "don't modify any files, jsut show difference"
ForeColor = &H8000000E&
Height = 255
Left = 120
TabIndex = 9
Top = 2520
Width = 4215
End
Begin VB.CheckBox Check2
Appearance = 0 'Flat
BackColor = &H8000000D&
Caption = "remove generated files after merge with existing code"
ForeColor = &H8000000E&
Height = 255
Left = 120
TabIndex = 8
Top = 2280
Width = 4215
End
Begin VB.CheckBox Check1
Appearance = 0 'Flat
BackColor = &H8000000D&
Caption = "update existing files only, don't create new files"
ForeColor = &H8000000E&
Height = 255
Left = 120
TabIndex = 7
Top = 2040
Value = 1 'Checked
Width = 4095
End
Begin VB.CommandButton Command4
Appearance = 0 'Flat
BackColor = &H80000014&
Caption = "Merge with existing files"
BeginProperty Font
Name = "Tahoma"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 855
Left = 120
Style = 1 'Graphical
TabIndex = 6
Top = 360
Width = 4695
End
Begin VB.Label Label1
Appearance = 0 'Flat
BackColor = &H8000000D&
Caption = "Location of existing files to be merged:"
ForeColor = &H8000000E&
Height = 255
Left = 120
TabIndex = 0
Top = 1320
Width = 4215
End
End
Begin VB.Frame Frame3
Appearance = 0 'Flat
BackColor = &H8000000D&
BorderStyle = 0 'None
Caption = "Step 2"
BeginProperty Font
Name = "Arial"
Size = 9.75
Charset = 204
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000E&
Height = 2895
Left = 5160
TabIndex = 12
Top = 0
Width = 4935
Begin VB.CommandButton Command10
Appearance = 0 'Flat
BackColor = &H80000014&
Caption = "Generate JavaScript Code"
BeginProperty Font
Name = "Tahoma"
Size = 12
Charset = 204
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 855
Left = 2520
Style = 1 'Graphical
TabIndex = 19
Top = 360
Width = 2295
End
Begin VB.CommandButton Command8
Appearance = 0 'Flat
BackColor = &H80000014&
Caption = "Build index file"
BeginProperty Font
Name = "Tahoma"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 120
Style = 1 'Graphical
TabIndex = 18
Top = 2040
Width = 2295
End
Begin VB.CommandButton Command7
Appearance = 0 'Flat
BackColor = &H80000014&
Caption = "Remove all generated files"
BeginProperty Font
Name = "Tahoma"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 2520
Style = 1 'Graphical
TabIndex = 17
Top = 2040
Width = 2295
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "Arial"
Size = 8.25
Charset = 204
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 120
TabIndex = 5
Text = "Text1"
Top = 1560
Width = 4695
End
Begin VB.CommandButton Command3
Appearance = 0 'Flat
BackColor = &H80000014&
Caption = "Generate Python Code"
BeginProperty Font
Name = "Tahoma"
Size = 12
Charset = 204
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 855
Left = 120
Style = 1 'Graphical
TabIndex = 4
Top = 360
Width = 2295
End
Begin VB.Label Label2
Appearance = 0 'Flat
BackColor = &H8000000D&
Caption = "Location for new files:"
BeginProperty Font
Name = "Arial"
Size = 8.25
Charset = 204
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000E&
Height = 255
Left = 120
TabIndex = 14
Top = 1320
Width = 4095
End
End
Begin VB.Frame Frame2
Appearance = 0 'Flat
BackColor = &H8000000D&
BorderStyle = 0 'None
Caption = "Step 1"
BeginProperty Font
Name = "Arial"
Size = 9.75
Charset = 204
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000E&
Height = 2895
Left = 120
TabIndex = 11
Top = 0
Width = 4935
Begin VB.CommandButton Command5
Appearance = 0 'Flat
BackColor = &H80000014&
Caption = "Scan current page only"
BeginProperty Font
Name = "Tahoma"
Size = 12
Charset = 204
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 120
MaskColor = &H00FFFFFF&
Style = 1 'Graphical
TabIndex = 3
Top = 2040
Width = 4695
End
Begin VB.CommandButton Command2
Appearance = 0 'Flat
BackColor = &H80000014&
Caption = "Scan opened MS Visio document"
BeginProperty Font
Name = "Tahoma"
Size = 12
Charset = 204
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 120
MaskColor = &H00FFFFFF&
Style = 1 'Graphical
TabIndex = 2
Top = 1200
Width = 4695
End
Begin VB.CommandButton Command1
Appearance = 0 'Flat
BackColor = &H80000014&
Caption = "Run Microsoft Visio"
BeginProperty Font
Name = "Tahoma"
Size = 12
Charset = 204
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 120
MaskColor = &H8000000E&
Style = 1 'Graphical
TabIndex = 1
Top = 360
UseMaskColor = -1 'True
Width = 4695
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim appVisio As Object
Dim docVisio As Object
Dim pagesVisio As Object
Dim pageVisio As Object
Dim shapesVisio As Object
Dim shapeVisio As Object
Dim shapeTo As Object
Dim shapeFrom As Object
Dim shapeCur As Object
Dim charactersVisio As Object
Dim cellColorVisio As Object
Dim cellStyleVisio As Object
Dim chars As Object
Dim celll As Object
Dim connects As Object
Dim connect As Object
Dim outputFilename As String
Dim outputFile
Dim FSO
Dim ts
Private Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)
Private Sub MakeVisioApplication()
Dim intSection As Integer
Dim intTries As Integer
On Error GoTo ErrorHandler
intSection = 1 'attempting GetObject...
Set appVisio = GetObject(, "Visio.Application")
intSection = 0 'resume normal error handling
' MsgBox "Found existing Microsoft Visio process"
Exit Sub
ErrorHandler:
If intSection = 1 Then
intTries = intTries + 1
If intTries < 5 Then
Sleep 500
Resume
Else
Set appVisio = CreateObject("Visio.Application")
MsgBox "Started new Microsoft Visio process, please open your document in that window and try again."
End If
Else
MsgBox Error$
End If
End Sub
Private Function CharacterFormatEnd(visShape As Visio.Shape, iBegin As Integer) As Integer
Dim visChars As Visio.Characters
Dim iLen As Integer, i As Integer, iFirstRow As Integer, iRow As Integer
iRow = -1
iLen = Len(visShape.Text)
For i = iBegin To iLen
Set visChars = visShape.Characters
visChars.Begin = i
visChars.End = i + 1
If iRow = -1 Then iFirstRow = visChars.CharPropsRow(visBiasLeft)
iRow = visChars.CharPropsRow(visBiasLeft)
If iRow <> iFirstRow Then
CharacterFormatEnd = i
Exit Function
End If
Next
CharacterFormatEnd = Len(visShape.Text)
End Function
Private Sub FixData()
Set pagesVisio = docVisio.Pages
Dim pageNumber As Integer
Dim Count As Integer
Dim diff As Integer
Dim arcs As Integer
Dim states As Integer
Dim labl As String
Dim i As Integer
pageNumber = 0
Count = 0
diff = 0
For Each pageVisio In pagesVisio
For Each shapeVisio In pageVisio.Shapes
If InStr(1, shapeVisio.Name, "arrow") > 0 Then
Count = Count + 1
Set chars = shapeVisio.Characters
Dim intCharCount As Integer
Dim intRunEnd As Integer
Dim intRunBegin As Integer
i = 0
intCharCount = chars.CharCount
While (i + 1 < intCharCount)
' Set the characters object to span one character
chars.Begin = i
chars.End = i + 1
' Find the set of characters that
' share formatting with this character
intRunEnd = chars.RunEnd(visCharPropRow)
intRunBegin = chars.RunBegin(Visio.VisRunTypes.visCharPropRow)
' Set the characters object to span this run
chars.Begin = intRunBegin
chars.End = intRunEnd
' Update i so that the next time through the loop, we'll look
' at the first character after this run.
i = intRunEnd
Set celll = shapeVisio.CellsSRC(visSectionCharacter, chars.CharPropsRow(Visio.visBiasLeft), visCharacterColor)
If InStr(celll.Formula, "9") > 0 Then
diff = diff + 1
chars.CharProps(visCharacterColor) = 3
ElseIf InStr(celll.Formula, "0;128;0") > 0 Then
diff = diff + 1
chars.CharProps(visCharacterColor) = 3
ElseIf InStr(celll.Formula, "0,128,0") > 0 Then
diff = diff + 1
chars.CharProps(visCharacterColor) = 3
ElseIf InStr(celll.Formula, "255;0;0") > 0 Then
diff = diff + 1
chars.CharProps(visCharacterColor) = 2
ElseIf InStr(celll.Formula, "255,0,0") > 0 Then
diff = diff + 1
chars.CharProps(visCharacterColor) = 2
ElseIf InStr(celll.Formula, "0;0;255") > 0 Then
diff = diff + 1
chars.CharProps(visCharacterColor) = 7
ElseIf InStr(celll.Formula, "0,0,255") > 0 Then
diff = diff + 1
chars.CharProps(visCharacterColor) = 7
ElseIf InStr(celll.Formula, "0;255;255") > 0 Then
diff = diff + 1
chars.CharProps(visCharacterColor) = 7
ElseIf InStr(celll.Formula, "0,255,255") > 0 Then
diff = diff + 1
chars.CharProps(visCharacterColor) = 7
ElseIf InStr(celll.Formula, "128;128;0") > 0 Then
diff = diff + 1
chars.CharProps(visCharacterColor) = 5
ElseIf InStr(celll.Formula, "128,128,0") > 0 Then
diff = diff + 1
chars.CharProps(visCharacterColor) = 5
ElseIf InStr(celll.Formula, "0;0;0") > 0 Then
diff = diff + 1
chars.CharProps(visCharacterColor) = 14
ElseIf InStr(celll.Formula, "0,0,0") > 0 Then
diff = diff + 1
chars.CharProps(visCharacterColor) = 14
End If
Wend
If shapeVisio.CellsU("LineColor").Formula <> 19 Then
shapeVisio.CellsU("LineColor").Formula = 19
diff = diff + 1
End If
ElseIf InStr(1, shapeVisio.Name, "state") > 0 Then
Count = Count + 1
If shapeVisio.CellsU("LineColor").Formula <> 19 Then
shapeVisio.CellsU("LineColor").Formula = 19
diff = diff + 1
End If
Set chars = shapeVisio.Characters
Set celll = shapeVisio.CellsSRC(visSectionCharacter, chars.CharPropsRow(Visio.visBiasLeft), visCharacterColor)
If celll.Formula <> "15" Then
chars.CharProps(visCharacterColor) = 15
diff = diff + 1
End If
ElseIf InStr(1, shapeVisio.Name, "label") > 0 Then
Count = Count + 1
If shapeVisio.CellsU("LineColor").Formula <> 19 Then
shapeVisio.CellsU("LineColor").Formula = 19
diff = diff + 1
End If
Set chars = shapeVisio.Characters
Set celll = shapeVisio.CellsSRC(visSectionCharacter, chars.CharPropsRow(Visio.visBiasLeft), visCharacterColor)
If celll.Formula <> "15" Then
chars.CharProps(visCharacterColor) = 15
diff = diff + 1
End If
End If
Next shapeVisio
Next pageVisio
Output.AddItem ("Total " + Str(Count) + " shapes scanned, made " + Str(diff) + " changes")
Output.ListIndex = Output.ListCount - 1
End Sub
Private Sub GetData(pageName As String)
Set pagesVisio = docVisio.Pages
Dim pageNumber As Integer
Dim arcs As Integer
Dim states As Integer
Dim labl As String
pageNumber = 0
For Each pageVisio In pagesVisio
arcs = 0
states = 0
labl = ""
If Len(pageName) > 0 Then
If StrComp(pageName, pageVisio.Name) Then
GoTo SKIP_PAGE_
End If
End If
If Left(pageVisio.Name, 1) = "_" Then
GoTo SKIP_PAGE_
End If
outputFile.WriteLine (Chr(10) & "page " & pageVisio.Name)
Output.AddItem ("page " & pageVisio.Name)
pageNumber = pageNumber + 1
Set shapesVisio = pageVisio.Shapes
For Each shapeVisio In shapesVisio
Set charactersVisio = shapeVisio.Characters
If InStr(1, shapeVisio.Name, "state") > 0 Then
outputFile.WriteLine (" state " & UCase(charactersVisio.Text))
Output.AddItem (" state " & UCase(charactersVisio.Text))
Output.ListIndex = Output.ListCount - 1
states = states + 1
ElseIf InStr(1, shapeVisio.Name, "arrow") > 0 Then
If shapeVisio.connects.Count > 1 Then
Set shapeFrom = shapeVisio.connects(1).ToSheet
Set shapeTo = shapeVisio.connects(2).ToSheet
If InStr(1, shapeFrom.Name, "state") > 0 And InStr(1, shapeTo.Name, "state") > 0 Then
outputFile.WriteLine (" link " & Replace(shapeVisio.Name, " ", "_") & " [" & UCase(shapeFrom.Characters.Text) & "] -> [" & UCase(shapeTo.Characters.Text) & "]")
Dim iBegin As Integer, iEnd As Integer, iRow As Integer, sColor As String, tmpTxt As String
tmpTxt = ""
iBegin = 0
For iRow = 0 To shapeVisio.RowCount(visSectionCharacter)
iEnd = CharacterFormatEnd(shapeVisio, iBegin)
charactersVisio.Begin = iBegin
charactersVisio.End = iEnd
Set cellColorVisio = shapeVisio.CellsSRC(visSectionCharacter, iRow, visCharacterColor)
Set cellStyleVisio = shapeVisio.CellsSRC(visSectionCharacter, iRow, visCharacterStyle)
If cellColorVisio = 0 Then
sColor = "(RGB(0;0;0))"
Else
sColor = Replace(cellColorVisio.Formula, "THEMEGUARD", "")
End If
sColor = Replace(sColor, ",", ";")
If sColor = "0" Or sColor = "" Then
sColor = "(RGB(0;0;0))"
ElseIf sColor = "2" Then
sColor = "(RGB(255;0;0))"
ElseIf sColor = "9" Then
sColor = "(RGB(0;128;0))"
ElseIf sColor = "4" Or sColor = "7" Then
sColor = "(RGB(0;0;255))"
ElseIf sColor = "11" Then
sColor = "(RGB(128;128;0))"
ElseIf sColor = "(RGB(127;0;0))" Then
sColor = "(RGB(128;0;0))"
ElseIf sColor = "(RGB(1;1;1))" Then
sColor = "(RGB(0;0;0))"
End If
sColor = Replace(sColor, "(RGB(", "[")
sColor = Replace(sColor, "))", "]")
sColor = Replace(sColor, ")", "]")
sColor = Replace(sColor, "RGB(", "[")
' Output.AddItem (" text [" & charactersVisio.Text & "] with color " & sColor)
' Output.ListIndex = Output.ListCount - 1
If sColor <> "[0;0;0]" And sColor <> "[255;0;0]" And sColor <> "[0;128;0]" And sColor <> "[0;0;255]" And sColor <> "[128;128;0]" Then
outputFile.WriteLine (" ERROR! text on link [" & shapeVisio.Name & "] have wrong color: " & sColor)
Output.AddItem ("ERROR! text on link [" & shapeVisio.Name & "] have wrong color: " & sColor)
Output.ListIndex = Output.ListCount - 1
End If
tmpTxt = tmpTxt & " " & "{" & sColor & "#" & cellStyleVisio & "#" & Replace(charactersVisio.Text, Chr(10), "\n") & "} " & Chr(10)
iBegin = iEnd
Next iRow
outputFile.WriteLine (tmpTxt)
' Output.AddItem (" link " & Replace(shapeVisio.Name, " ", "_") & " [" & UCase(shapeFrom.Characters.Text) & "] -> [" & UCase(shapeTo.Characters.Text) & "]")
' Output.ListIndex = Output.ListCount - 1
arcs = arcs + 1
' Output.Refresh
End If
Else
outputFile.WriteLine (" ERROR! link [" & shapeVisio.Name & "] have only " & shapeVisio.connects.Count & " connects")
Output.AddItem ("ERROR! link [" & shapeVisio.Name & "] have only " & shapeVisio.connects.Count & " connects")
Output.ListIndex = Output.ListCount - 1
' Output.Refresh
End If
ElseIf InStr(1, shapeVisio.Name, "label") > 0 Then
outputFile.WriteLine (" label " & Replace(charactersVisio.Text, Chr(10), "\n"))
Output.AddItem (" label " & Replace(charactersVisio.Text, Chr(10), " "))
Output.ListIndex = Output.ListCount - 1
' Output.Refresh
labl = Replace(charactersVisio.Text, Chr(10), " ")
End If
Next shapeVisio
If states = 0 Then
outputFile.WriteLine (" ERROR! no states found on page " & pageVisio.Name)
Output.AddItem ("ERROR! no states found on page " & pageVisio.Name)
Output.ListIndex = Output.ListCount - 1
' Output.Refresh
End If
If arcs = 0 Then
outputFile.WriteLine (" ERROR! no arcs found on page " & pageVisio.Name)
Output.AddItem ("ERROR! no arcs found on page " & pageVisio.Name)
Output.ListIndex = Output.ListCount - 1
' Output.Refresh
End If
If labl = "" Then
outputFile.WriteLine (" ERROR! no label found on page " & pageVisio.Name)
Output.AddItem ("ERROR! no label found on page " & pageVisio.Name)
Output.ListIndex = Output.ListCount - 1
' Output.Refresh
End If
SKIP_PAGE_:
Next pageVisio
Output.AddItem ("DONE, number of pages is " & pageNumber)
Output.ListIndex = Output.ListCount - 1
' Output.Refresh
End Sub
Private Sub GetIndex()
Set pagesVisio = docVisio.Pages
Dim pageNumber As Integer
Dim arcs As Integer
Dim states As Integer
Dim labl As String
pageNumber = 0
For Each pageVisio In pagesVisio
arcs = 0
states = 0
labl = ""
outputFile.WriteLine ((pageNumber) & " " & pageVisio.Name)
Output.AddItem ("page " & pageNumber & " " & pageVisio.Name)
pageNumber = pageNumber + 1
Next pageVisio
Output.AddItem ("DONE, number of pages is " & pageNumber)
Output.ListIndex = Output.ListCount - 1
End Sub
Sub ScanCurrentDocument()
Dim sArgs() As String
Dim iLoop As Integer
outputFilename = "./data.txt"
Output.AddItem ("Looking for Microsoft Visio")
Output.ListIndex = Output.ListCount - 1
' Output.Refresh
MakeVisioApplication
Set docVisio = appVisio.ActiveDocument
If docVisio Is Nothing Then
Output.AddItem ("Please Open Microsoft Visio Document")
Output.ListIndex = Output.ListCount - 1
' Output.Refresh
GoTo EXIT_
End If
Set outputFile = FSO.CreateTextFile(outputFilename)
Output.AddItem ("Scanning current Microsoft Visio document")
Output.ListIndex = Output.ListCount - 1
' Output.Refresh
GetData ("")
outputFile.Close
Output.AddItem ("File " + outputFilename + " created")
Output.ListIndex = Output.ListCount - 1
' Output.Refresh
EXIT_:
End Sub
Sub ScanCurrentPage()
Dim sArgs() As String
Dim iLoop As Integer
outputFilename = "./data.txt"
Output.AddItem ("Looking for Microsoft Visio")
Output.ListIndex = Output.ListCount - 1
' Output.Refresh
MakeVisioApplication
Set docVisio = appVisio.ActiveDocument
If docVisio Is Nothing Then
Output.AddItem ("Please Open Microsoft Visio Document")
Output.ListIndex = Output.ListCount - 1
' Output.Refresh
GoTo EXIT_
End If
Set outputFile = FSO.CreateTextFile(outputFilename)
Output.AddItem ("Scanning current page")
Output.ListIndex = Output.ListCount - 1
' Output.Refresh
GetData (appVisio.ActivePage.Name)
outputFile.Close
Output.AddItem ("File " + outputFilename + " created")
Output.ListIndex = Output.ListCount - 1
' Output.Refresh
EXIT_:
End Sub
Sub FixCurrentDocument()
Dim sArgs() As String
Dim iLoop As Integer
'outputFilename = "./fix.txt"
Output.AddItem ("Looking for Microsoft Visio")
Output.ListIndex = Output.ListCount - 1
' Output.Refresh
MakeVisioApplication
Set docVisio = appVisio.ActiveDocument
If docVisio Is Nothing Then
Output.AddItem ("Please Open Microsoft Visio Document")
Output.ListIndex = Output.ListCount - 1
' Output.Refresh
GoTo EXIT_
End If
'Set outputFile = FSO.CreateTextFile(outputFilename)
Output.AddItem ("Scanning current Microsoft Visio document")
Output.ListIndex = Output.ListCount - 1
' Output.Refresh
FixData
'outputFile.Close
'Output.AddItem ("File " + outputFilename + " created")
'Output.ListIndex = Output.ListCount - 1
' Output.Refresh
EXIT_:
End Sub
Sub BuildIndexWholeDocument()
Dim sArgs() As String
Dim iLoop As Integer
outputFilename = "./index.txt"
Output.AddItem ("Looking for Microsoft Visio")
Output.ListIndex = Output.ListCount - 1
MakeVisioApplication
Set docVisio = appVisio.ActiveDocument
If docVisio Is Nothing Then
Output.AddItem ("Please Open Microsoft Visio Document")
Output.ListIndex = Output.ListCount - 1
GoTo EXIT_
End If
Set outputFile = FSO.CreateTextFile(outputFilename)
Output.AddItem ("Scanning current Microsoft Visio document")
Output.ListIndex = Output.ListCount - 1
GetIndex
outputFile.Close
Output.AddItem ("File " + outputFilename + " created")
Output.ListIndex = Output.ListCount - 1
EXIT_:
End Sub
Private Sub Command1_Click()
' On Error Resume Next
MakeVisioApplication
End Sub
Private Sub Command2_Click()
' On Error Resume Next
ScanCurrentDocument
End Sub
Private Sub Command3_Click()
Dim cmd As String
Dim txtline As String
Dim fin As Integer
Dim oShell As Object
cmd = "python data2py.py ./data.txt ./structure.txt " & Text1.Text
Output.AddItem ("Running command:")
Output.ListIndex = Output.ListCount - 1
Output.AddItem (" [" & cmd & "]")
Output.ListIndex = Output.ListCount - 1
Set oShell = CreateObject("Wscript.Shell")
oShell.Run "%COMSPEC% /c " & cmd & " > generate.txt", 0, True
fin = FreeFile
If Dir("generate.txt") <> "" Then
Open "generate.txt" For Input As #fin
Do While Not EOF(fin)
Line Input #fin, txtline$
Output.AddItem (txtline$)
Output.ListIndex = Output.ListCount - 1
Loop
Close #fin
End If
End Sub
Private Sub Command4_Click()
Dim cmd As String
Dim txtline As String
Dim fin As Integer
Dim oShell As Object
cmd = "python merge.py ./structure.txt " & Text1.Text & " " & Combo1.Text & " " & Check1.Value & " " & Check2.Value & " " & Check3.Value
Output.AddItem ("Running command " & cmd)
Output.ListIndex = Output.ListCount - 1
Set oShell = CreateObject("Wscript.Shell")
oShell.Run "%COMSPEC% /c " & cmd & " > merge.txt", 0, True
fin = FreeFile
If Dir("merge.txt") <> "" Then
Open "merge.txt" For Input As #fin
Do While Not EOF(fin)
Line Input #fin, txtline$
Output.AddItem (txtline$)
Output.ListIndex = Output.ListCount - 1
Loop
Close #fin
End If
End Sub
Private Sub Command5_Click()
' On Error Resume Next
ScanCurrentPage
End Sub
Private Sub Command6_Click()
Combo1.AddItem (Combo1.Text)
End Sub
Private Sub Command7_Click()
Dim oShell As Object
Dim cmd As String
cmd = "del " & Replace(Text1.Text, "/", "\\") & "\\*.py "
Output.AddItem ("Running command " & cmd)
Output.ListIndex = Output.ListCount - 1
Set oShell = CreateObject("Wscript.Shell")
oShell.Run "%COMSPEC% /c " & cmd, 0, True
End Sub
Private Sub Command8_Click()
' On Error Resume Next
BuildIndexWholeDocument
End Sub
Private Sub Form_Load()
Set FSO = CreateObject("Scripting.FileSystemObject")
Dim i As Integer
Dim line, txt As String
Dim lines() As String
Dim inipath As String
inipath = App.Path & IIf(Right$(App.Path, 1) <> "\", "\", "") & "visio2python.ini"
Output.AddItem ("Current folder: " & App.Path)
Output.ListIndex = Output.ListCount - 1
If FSO.FileExists(inipath) Then
Set ts = FSO.opentextfile(inipath)
txt = ts.ReadAll
ts.Close
lines = Split(txt, vbNewLine)
For Each line In lines
i = InStr(1, line, "generated")
If i = 1 Then
Text1.Text = Right(line, Len(line) - Len("generated") - 1)
End If
i = InStr(1, line, "existed")
If i = 1 Then
Combo1.AddItem (Right(line, Len(line) - Len("existed") - 1))
Combo1.Text = Right(line, Len(line) - Len("existed") - 1)
End If
Next line
Output.AddItem ("Load path locations from " & inipath)
Output.ListIndex = Output.ListCount - 1
' Output.Refresh
Else
Output.AddItem ("Not found ini file in " & inipath)
Output.ListIndex = Output.ListCount - 1
Text1.Text = "./generated"
Combo1.AddItem ("./")
Combo1.Text = "./"
End If
ChDrive App.Path
ChDir App.Path
End Sub