×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Smart Art

Smart Art

RE: Smart Art

https://docs.microsoft.com/en-us/office/vba/api/ov...

However, perhaps you might want to outline what you are trying to do and we might be able to be more helpful. You attached file contains code that has no obvious reference to SmartArt that I can see, so not a useful attachment given your question.

RE: Smart Art

Sorry - I don't have the time (or inclination) to wade through over 3.5k lines of code to try and figure out where you are struggling.

Providing code is greart, but to start with we just need to see the code where you are having the problem, or where you need guidance.

But right now, I still donm't understand exactly what you are trying to do.

You may think that " wanted to copy text from a sheet automatically into a list style smart art" explains everything, but it isn't clear at all. At least not to me.

RE: Smart Art

Why not just click on the record macro button and then do what you would want to do manually with the smart art and see what code gets generated.

It will be something like

CODE

call activesheet.shapes.addsmartart(application.smartart.layouts(...)).select
... 

RE: Smart Art

You can't macro record smart art ...

RE: Smart Art

From the docs link provided by strongm....

You can't do what you want to do.

You can't do very much at all to manipulate SmartArt via VBA. Which is too bad really.

RE: Smart Art

A macro recorder can help a little when you create a smart art, esp. to get layout string reference. In the next step one can experiment a bit with already created smart art, get reference to it (it's a shape), in a break mode examine model in Locals window. Finally, object browser shows properties and methods.
Smart art does not accept VBA mistakes, excel closes without warning, it's a good habit to save file before testing the code.

Here's my first code with SmartArt after few tests, for active sheet:

CODE -->

Sub test()
Dim shpSmartArt As Shape
Dim strSAname As String
strSAname = "mySmartArt"
' create sample SmartArt
Set shpSmartArt = CreateSmartArt(strSAname)
' move 'child node 3' up
shpSmartArt.SmartArt.Nodes(1).Nodes(3).ReorderUp
' change 'child node 3' text, now second cild node
shpSmartArt.SmartArt.Nodes(1).Nodes(2).TextFrame2.TextRange = "changed text"
End Sub

Public Function CreateSmartArt(sName As String) As Shape
Dim shpSmartArt As Shape
' create sample SmartArt
Set shpSmartArt = ActiveSheet.Shapes.AddSmartArt(Application.SmartArtLayouts("urn:microsoft.com/office/officeart/2008/layout/LinedList"))
With shpSmartArt
    .Name = sName
    With .SmartArt
        'remove all except root default child nodes
        For i = .AllNodes.Count To 2 Step -1
            .AllNodes.Item(i).Delete
        Next i
        With .Nodes(1)
            .TextFrame2.TextRange = "root node"
            For i = 1 To 5
                With .Nodes.Add
                    .TextFrame2.TextRange = "child node " & i
                    .Demote
                End With
            Next i
        End With
    End With
End With
Set CreateSmartArt = shpSmartArt
End Function 

combo

RE: Smart Art

(OP)
COMBO
Thanks for the really useful post. I had nothing on SmartArt manipulation.
C57

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close