Consulting

Results 1 to 2 of 2

Thread: Find and Replace from UserForm

  1. #1
    VBAX Newbie
    Joined
    Mar 2006
    Posts
    2
    Location

    Question Find and Replace from UserForm

    I'm using Visio 2003 and have created a Userform with multiple text fields. I'd like the Submit button when clicked to Find a value throught all my diagrams and then replace that value with what was inputted by the User in the associated text field.

    Any help would be much appreciated.

    Here's what I tried and keep getting this error:

    run time error 424'
    object required

     
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = "[Promotion Name]"
        .Replacement.Text = TextBox1.Value
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Last edited by Aussiebear; 05-05-2025 at 07:31 AM.

  2. #2
    VBAX Newbie
    Joined
    Mar 2006
    Posts
    2
    Location

    This works for some shapes, but not all areas

    The last code was find and replace for MS word

    [Code]
    Dim iDocumentCount As Integer
    iDocumentCount = Documents.Count
    Dim iPageCount As Integer
    iPageCount = Documents(1).Pages.Count
    Dim iCurrentPage As Integer
    For iCurrentPage = 1 To iPageCount
    iShapeCount = Documents(1).Pages(iCurrentPage).Shapes.Count
    Dim iCurrentShape As Integer
    For iCurrentShape = 1 To iShapeCount
    Documents(1).Pages(iCurrentPage).Shapes(iCurrentShape).Text = Replace(Documents(1).Pages _
    (iCurrentPage).Shapes(iCurrentShape).Text, "CHECK ME", TextBox1.Text)
    Next
    Next
    [/VBA]
    Last edited by Aussiebear; 05-05-2025 at 07:30 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •