Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search Duplicate Text?

Status
Not open for further replies.

samuelhk

Technical User
Mar 22, 2007
13
HK
Any idea can reach caption question?
 
I can probably help you with this, but I really need you to be MUCH more specific. Your question is to vague. Can you please provide more details?
 
hi Alcedes,
I do alot of word processing in Visio. e.g. Label the drawing unique items in hundred - computer name : samuel01 samuel02 ...samuel100

Some labels will be duplicated. e.g. samuel99 samuel99

So that need a way to find the duplicate text in visio to eliminate my typing fault
 
Sub ReLabel()

Dim ticker As Integer
Dim theshapes As Shapes
Dim counter As Integer
Dim reportback As String

Set theshapes = ActivePage.Shapes

Dim thisshape As Shape
Dim shapenames As String
Dim ReText(999999)

For Each thisshape In theshapes
ticker = ticker + 1
ReText(ticker) = thisshape.Name
Next

For t = 1 To ticker
counter = counter + 1
CurName = Application.ActivePage.Shapes(ReText(t)).Name
For x = 1 To ticker
If Application.ActivePage.Shapes(ReText(x)).Name <> Application.ActivePage.Shapes(ReText(t)).Name Then


If CurName = Application.ActivePage.Shapes(ReText(x)).Text Then
reportback = reportback & Application.ActivePage.Shapes(ReText(x)).Name & vbCrLf
ActiveWindow.Select Application.ActivePage.Shapes(ReText(x)), visSelect
NewText = InputBox(Application.ActivePage.Shapes(ReText(x)) & " has a duplicate label. What would you like to change it to? ")
Application.ActivePage.Shapes(ReText(x)).Text = NewText
End If
End If
Next x
Next t
MsgBox "The following shapes have had their text changed:" & vbCrLf & reportback

End Sub


 
And of course, as always when running fresh code, save your document to another location using a different name. Run the code and be sure it works. This way, you do not hose your work.
 
Hi Alcedes,

I copy and run it in visio macro.
But it seems dosn't work. Just appear "The following shapes have had their text changed"

Any idea? thx a lot.
 
Well this macro only runs on the current page. So you have to click on the page tab at the bottom of the screen that you wish to check.

Also, if it returns a message box that claims nothing was changed, then basically, there were no shapes on the page that had text that matched another shapes text.
 
If you do not want to get into coding, you can use Visio's reporting feature and sort by name. You will still need to review the list for duplicates, but they should be easy to spot. (or you can extract the report to Excel)

John... Visio MVP - Visio.MVPs.org
 
Hi VisioMVP,
yes, this approach is good for me. you are excellent
Thank a lot!! :)

 
One of the fun things with Visio is trying to do things WITHOUT coding. How far can you go with just using the shapesheet.

Sometimes it is like that scene from Indian Jones where after demonstrating his prowess with the whip, he just reaches for his revolver.

John... Visio MVP - Visio.MVPs.org
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top