View Full Version : Visio VBA - Find and Replace from UserForm

03-02-2006, 01:57 PM
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

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

03-09-2006, 01:07 PM
The last code was find and replace for MS word

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)