I've been working on this code... But I need input!
You know how you work on a code so long you're brain fries? Well that's where I am. I feel this should be easy but leave it to me to make thing complicated.
Okay - I have existing text on page. I select text on page, type new text in textbox and click "add to page" Which should add to page OR if text is selected replace text with new text.
ISSUE : Code replaces anything I have selected. If I have a rectangle selected it will be replaced with new text. I only need the code to do 2 things. Add to page if nothing is selected OR replace live text if live text is selected.
Set sr = ActiveSelectionRange sr.GetPosition X, Y Optimization = True Set textShape = ActiveLayer.CreateArtisticText(ActiveLayer.Page.CenterX, 0, TextBox.Text, 0, cdrCharSetMixed, , 40) On Error Resume Next textShape.Text.Story.font = ListAllFonts textShape.Text.Story.Size = sr(1).Text.Story.Size textShape.Fill.UniformColor = sr(1).Fill.UniformColor textShape.Text.Story.CharSpacing = 15 textShape.Text.Story.WordSpacing = 100 textShape.OrderToFront
If sr.Count = 1 Then ' here might be my issue? I don't know... textShape.SetPosition X, Y Else textShape.AlignAndDistribute 3, 3, 2, 0, False, 2 End If sr(1).Delete
Maybe code below can help
Sub ReplaceText()Dim txtFIND As String Dim txtREPLACE As String 'The new word to replace the oldDim p As PageIf ActiveShape.Type <> cdrTextShape Then ActiveDocument.AddPages (1): Exit SubtxtFIND = ActiveShape.Text.SelectiontxtREPLACE = InputBox("New text", "Enter text", "")For Each p In ActiveDocument.Pagesp.TextReplace txtFIND, txtREPLACE, True, FalseNext pEnd Sub