I'm trying to use ChatGPT to create a small macro to look for artistic text in my document that is using points as the unit of measurement for the vertical spacing and change it to use % of the character height. When I open PDFs from outside sources the artistic text is always using points as the unit. If I resize the text, the spacing does not size with it. I have to manually change the text to use a percentage of the character height to have it resize correctly.
This is the macro as given by ChatGPT. It runs but does not actually change the vertical spacing unit for the text. Any help would be appreciated.
Sub ConvertVerticalSpacingUnits() Dim sr As ShapeRange Dim s As Shape Dim txt As Text
' Search for all artistic text shapes in the document Set sr = ActivePage.Shapes.FindShapes(Type:=cdrArtisticTextShape)
For Each s In sr If s.Type = cdrArtisticTextShape Then Set txt = s.Text
' Check if vertical spacing unit is in points If txt.Paragraphs.VerticalSpacingUnit = cdrSpacingPoints Then ' Change the unit to percentage of character height txt.Paragraphs.VerticalSpacingUnit = cdrSpacingPercentOfCharacterHeight End If End If Next s
MsgBox "All applicable artistic text shapes have been updated to use % of character height for vertical spacing.", vbInformationEnd Sub
You could try this:
Sub ArtisticText_set_pct_char_height_spacing() Dim sr As ShapeRange Dim s As Shape Set sr = ActivePage.Shapes.FindShapes(, cdrTextShape) For Each s In sr If s.Text.Type = cdrArtisticText Then If Not s.Text.Story.LineSpacingType = cdrPercentOfCharacterHeightLineSpacing Then s.Text.Story.SetLineSpacing cdrPercentOfCharacterHeightLineSpacing End If End If Next s End Sub
Dang you beat me to it! I was trying to get chatgpt and claud.ai to work but they didn't know how to get the LineSpacingType.
Thanks! That worked!
ChatGPT is the only AI that comes close to working for me. I've been able to build small macros using it but I find myself coming to this forum to look at examples if it's too complicated. And I realized that AI just doesn't format the code correctly. If Eskimo hadn't responded so quickly, my next step would have been to record a script of myself changing the attribute manually, then reading the code to see what changes are needed. Then I would have posted the results to ask for help formatting it.
Another tip that got me close, in VBA editor press F2 to bring up the object browser, then search for "spacing" and that brought up the LineSpacingType setting that ChatGPT was missing. From there I could google how to use it.