Is there a possible way to update wordart's text using macro?

masterms

New Member
Joined
Apr 27, 2024
Messages
7
Office Version
  1. 2013
  2. 2007
Platform
  1. Windows
Is there a possible way to update wordart's text using macro?

I got a wordart with text "aaa" in it, I want to update text to "bbb" using vba

office 2007
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
VBA Code:
Sub FindWordArtTextInWord2007()    
  Dim doc As Document    
  Dim shp As Shape    
  Dim msg As String    
  Set doc = ActiveDocument    
  msg = "Wordart content:" & vbCrLf    
  For Each shp In doc.Shapes       
       If shp.Type = msoTextBox Or shp.Type = msoAutoShape Then   
              If Not shp.TextFrame Is Nothing And Not shp.TextFrame.TextRange Is Nothing Then
                     msg = msg & shp.TextFrame.TextRange.Text & vbCrLf 
              End If
       End If
Next shp 

MsgBox msg, vbInformation, "WordArt text :"        
 Set doc = NothingEnd Sub

always return nothing or ##000##
 
Upvote 0
See if the following sub works for you:
VBA Code:
Sub FindWordArtTextInWord2007()
    Dim doc As Document
    Dim shp As Shape
    Dim msg As String
    Set doc = ActiveDocument
    msg = "Wordart content:" & vbCrLf
    For Each shp In doc.Shapes
        If shp.Type = msoTextEffect Then
            If Not shp.TextEffect Is Nothing Then
                msg = msg & shp.TextEffect.Text & vbCrLf
            End If
        End If
    Next shp
    MsgBox msg, vbInformation, "WordArt text :"
    Set doc = Nothing
End Sub
 
Upvote 0
Sub FindWordArtTextInWord2007() Dim doc As Document Dim shp As Shape Dim msg As String Set doc = ActiveDocument msg = "Wordart content:" & vbCrLf For Each shp In doc.Shapes If shp.Type = msoTextEffect Then If Not shp.TextEffect Is Nothing Then msg = msg & shp.TextEffect.Text & vbCrLf End If End If Next shp MsgBox msg, vbInformation, "WordArt text :" Set doc = Nothing End Sub
still nothing
 
Upvote 0
I ran your code as posted in post #2 and it worked for me:

1714264790768.png


In my case it sees the WordArt I added as type msoTextBox.
 
Upvote 0
I found out why it doesn't work for me, in Office 2007 , wordart is a inlineShape, which is not a regular shape!
but I still can't find a way to change inlineshape's text

frustrating

any help?
 
Upvote 0
update:
"inlineshape" only happens when it's position is sett to inline , other are normal shape.
eg.when setting to "floating above text" or "under text", which is normal shape.

but I need inline
 
Upvote 0
Seems like you could just change this bit of code...
VBA Code:
Dim shp As Object
For Each shp In doc.InlineShapes
If shp.Type = msoTextEffect Then
If Not shp.TextEffect Is Nothing Then
    msg = msg & shp.TextEffect.Text & vbCrLf
End If
End If
Next shp
HTH. Dave
 
Upvote 0

Forum statistics

Threads
1,215,644
Messages
6,125,993
Members
449,279
Latest member
Faraz5023

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top