0
votes

I have the follow code that is running in an Excel and it's calling a PowerPoint slide. I am setting a text to each existing node of the SmartArt and it's working. However, I am getting error when I use AddNode method (oSmartArt.AllNodes.Add.AddNode). What am I doing wrong?

Set oSmartArt = d_ppt_output.Slides(SLIDE_SMART).Shapes("MyList").SmartArt

x = 1
While Cells(x, 1).Text <> ""
    If x > oSmartArt.Nodes.Count Then
        oSmartArt.AllNodes.Add.AddNode ''''' ERROR IS HERE!
    End If

    oSmartArt.AllNodes(x).Shapes.TextFrame2.TextRange.Text = ActiveSheet.Cells(x, 2).Text
    x = x + 1
Wend

I also replaced oSmartArt.AllNodes.Add.AddNode by oSmartArt.Nodes.Add.AddNode but I get the same problem.

The error is: -2147467259 (80004005) Method 'add' of object 'SmartArtNodes' failed

The whole code can by found here - https://drive.google.com/drive/folders/1_O79iiG7hbBjMHMSH6kZGkWmjN1WGorR?usp=sharing

1
I found the description of this error (-2147467259 80004005) - docs.microsoft.com/en-us/office/troubleshoot/excel/… but I don't understand what to do...Braulio

1 Answers

0
votes

As posted, your code doesn't run. You can't reference a slide with a name that's not in quotes. I created a super-simple version in PowerPoint that starts with a 5-member SmartArt. This is running without an error. It adds a new node and fills in the text as expected:

Sub Test()
    Set oSmartArt = ActivePresentation.Slides(1).Shapes(2).SmartArt
    oSmartArt.AllNodes.Add.AddNode
    oSmartArt.AllNodes(6).Shapes.TextFrame2.TextRange.Text = "Wha?"
End Sub