adding text transform section from excell macro

Started by ddj, January 12, 2018, 01:19:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ddj

Hi,
Would anyone know how to add a section from a macro that runs from an excell spreadsheet?
Been searching all over the place without much luck...

Basicly I can access whats there , but can't seem to figure out on how to add a section.
Any help would be greatly appriciated.

    Dim appVisio As Object
    Dim vsoShape As Object

    Set appVisio = CreateObject("visio.application")
     
    appVisio.Documents.AddEx "", visMSUS, 0
    appVisio.Visible = True
   

        Set vsoShape = appVisio.ActivePage.DrawRectangle1,4,4,1)
   
        vsoShape.Cells("FillForegndTrans") = 1     
        vsoShape.Cells("Char.Size").Result("pt") = 50
        vsoShape.Text = world(9, i)

Surrogate

Quote from: ddj on January 12, 2018, 01:19:37 PM
    Dim appVisio As Object
    Dim vsoShape As Object

    Set appVisio = CreateObject("visio.application")
     
    appVisio.Documents.AddEx "", visMSUS, 0
    appVisio.Visible = True
   

        Set vsoShape = appVisio.ActivePage.DrawRectangle1,4,4,1)
' there lose (
   
        vsoShape.Cells("FillForegndTrans") = 1     
        vsoShape.Cells("Char.Size").Result("pt") = 50
        vsoShape.Text = world(9, i)
' if variable i don't define, it mean that variable's value equal 0, and you get error

check my comments. this code works
Sub ddj()
    Dim appVisio As Object
    Dim vsoShape As Object
    Set appVisio = CreateObject("visio.application")
    appVisio.Documents.AddEx "", visMSUS, 0
    appVisio.Visible = True
    Set vsoShape = appVisio.ActivePage.DrawRectangle(1, 4, 4, 1)
    vsoShape.Cells("FillForegndTrans") = 1
    vsoShape.Cells("Char.Size").Result("pt") = 50
    vsoShape.Text = Cells(9, 1)
End Sub



ddj

Sorry, that was a sloppy "copy-paste-and-get-rid-of-unneccesary-stuff" from my part from a bigger routine the code actualy worked,

but what I can't figure out is how to add the section "transform text" to the shapesheet of the shape.
(trying to get the text above the shape and scale smaller when it's larger then the shape lenght)

I tried recording a macro in visio but what comes up there doesn't quite work from an excell macro, maybe I'm missing a reference?

wapperdude

Not at my computer are the moment, but since you're doing this from Excel, you need to make sure VBA has / access to Visio object model.  Anyway, it's starting point.

From this post,   http://visguy.com/vgforum/index.php?topic=7450.0
there's this note: 
' The following references are used:
'   Visual Basic for Applications
'   Microsoft Visio Type Library
'   OLE Automation
'   Microsoft Office Object Library
'   Microsoft Excel Object Library
'   You'll have to choose the appropriate versions based upon your installation


Wapperdude
Visio 2019 Pro

sockmonkeyrevolt

If I'm reading you right, you are getting it to create the rectangle shape you just want to add the Text Transform section to the shape sheet

I think it should be


vsoShape.AddRow visSectionObject, visRowTextXForm, visTagDefault



I'm just in visio right now, but that added that section to a shape I didn't have it in. TextTransform doesn't seem to be an enumerated section that you can use the AddSection method to add, seems like it has to be added by adding a row.

ddj

@sockmonkeyrevolt  Yup, exactly, And I had that part figured out but it kept trowing me errors, I was totaly clueless about why until....

@wapperdude You are my new hero !! Apperantly all i needed to do was add the
Microsoft Visio Type Library *rolls eyes*
I feel so stupid now after hours of searching how or why.

Anyway, now that I have that sorted, should I keep these all as object or go to the actual type?

"Dim vsoShape As Object"
or go for
"Dim vsoShape As Visio.Shape".

wapperdude

Visio 2019 Pro