Run visio add-on from VBA script

Started by ivan, February 16, 2010, 03:43:34 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ivan

I need to create an array of shapes. It can be done with array shapes Add-on. but i can't get it work from VBA module
there's example to get addon names
QuoteDim strMasterNames() As String
   Dim intLowerBound As Integer
   Dim intUpperBound As Integer

   Visio.Application.Addons.GetNames strMasterNames
   intLowerBound = LBound(strMasterNames)
   intUpperBound = UBound(strMasterNames)
   Debug.Print ActiveDocument; " Lower bound:"; intLowerBound; "Upper bound:"; intUpperBound

   While intLowerBound <= intUpperBound

       Debug.Print strMasterNames(intLowerBound)
       intLowerBound = intLowerBound + 1

   Wend
But how can i know what parameters i can pass ? i can lauch it
 Visio.Application.Addons("Array Shapes...").Run ("")
but i failed to guess what parametes i need (

Yacine

Hi,
If you are already in VBA, why bother with the plugin?
You are so much more flexible by modifiying the properties of the next created shape.  ;D
Yacine

wapperdude

Have you tried recording a macro, and walk thru the steps to create your array?  The recorded macro should show what needs to be placed in your code.

Wapperdude
Visio 2019 Pro

ivan

#3
running addon doesnt record into macro for some reason (
QuoteYou are so much more flexible by modifiying the properties of the next created shape.
good idea. i made my own macro several hours ago.
though i'm still curious if i can use addon via macro... can be useful sometimes

Paul Herber

I would guess that the addon doesn't take parameters, as soon as the addon is initiated it will ask for its operational values via the dialog box. There is the possibility of entering the values using a Windows macro recorder. Software exists that can automate Windows tasks by recording keyboard and mouse actions and then playing them back. Maybe this route would be worth exploring.

Search the web for 'windows keyboard and mouse recorder'.

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

Yacine




Sub VBAarray()
    If Application.ActiveWindow.Selection.Count < 0 Then Exit Sub
    For i = 1 To 100
    Application.ActiveWindow.Selection.Duplicate
    Application.ActiveWindow.Selection.Move sin(i/10),0
    Next i
End Sub
Yacine

ivan

Yacine
thanks , but  i've got my own script already - it's about any addon atm  "i'm still curious if i can use addon via macro"

QuoteI would guess that the addon doesn't take parameters
and we can only guess ? is there any way to get possible parameters ?

ivan

same question. but i need to use CAD convertion add-on/ any idea how to launch it with file path parameter ?

Yacine

#8
spent an hour searching for an overview of the addon parameters.
Does any of you out there have a good link?

Alternatively one could investigate them via VBA.
Yacine

ivan

as about CAD convertion - it was simple ) hit the forst guess.
i made this code
Sub test()

nums = Array(2, 3, 5, 10, 12, 13, 16, 18, 19, 20, 22, 27, 29, 30, 32, 33, 34, 38, 40)

For Each num In nums


found = False

    Dim strMasterNames() As String
    Dim intLowerBound As Integer
    Dim intUpperBound As Integer


    ActiveDocument.Pages.GetNames strMasterNames
    intLowerBound = LBound(strMasterNames)
    intUpperBound = UBound(strMasterNames)
    Debug.Print ActiveDocument; " Lower bound:"; intLowerBound; "Upper bound:"; intUpperBound


    While intLowerBound <= intUpperBound
   
       
       ' Debug.Print strMasterNames(intLowerBound) & vsoPage1

        If strMasterNames(intLowerBound) = CStr(num) Then
        found = True
        End If
       
        intLowerBound = intLowerBound + 1
    Wend

Debug.Print found

If Not (found) Then
    Set vsoPage1 = ActiveDocument.Pages.Add
    vsoPage1.Name = CStr(num)
    vsoPage1.Background = False
    vsoPage1.Index = ActiveDocument.Pages.Count + 1
End If


Set vsoPage1 = ActiveDocument.Pages.ItemU(CStr(num))

   
Visio.Application.Addons("Convert CAD Drawings...").Run ("I:\sx " & num & ".DWG")


ActiveWindow.SelectAll


ActiveWindow.Selection.Cut

Application.AlertResponse = 7

ActiveWindow.Close

Application.AlertResponse = 0

Application.ActiveWindow.Page = Application.ActiveDocument.Pages.ItemU(CStr(num))

ActiveWindow.Paste
Next num

'Application.Settings.ShowFileSaveWarnings = True
End Sub

converts banch of files. result is saved on specified pages
any ideea how to improve this code ?