Visio Guy

Visio Discussions => Programming & Code => Topic started by: SubPlanner on January 08, 2016, 04:14:33 PM

Title: [Solved] Change all Lower Case text to Upper Case in Page names with VBA
Post by: SubPlanner on January 08, 2016, 04:14:33 PM
What would be the code to use to change all the page names from lower case to upper case using VBA.

Any help would be appreciated.

SubPlanner
Title: Re: Change all Lower Case text to Upper Case in Page names with VBA
Post by: JohnGoldsmith on January 08, 2016, 04:50:47 PM
Hi,

You can just loop through (http://visualsignals.typepad.co.uk/vislog/2007/11/looping-through.html) the pages and change the names as you go:

Public Sub PagesToUpper(ByRef vDoc As Visio.Document)
If Not vDoc Is Nothing Then
    Dim vPag As Visio.Page
    For Each vPag In vDoc.Pages
        vPag.Name = UCase(vPag.Name)
        'Uncomment next line to force NameU to be the same as Name
        'vPag.NameU = vPag.Name
    Next
End If
End Sub


You can then call that code like this:

Public Sub ChangePages()
    Call PagesToUpper(ThisDocument) 'Change ThisDocument as required
End Sub


Hope that helps.

Best regards

John
Title: Re: Change all Lower Case text to Upper Case in Page names with VBA
Post by: SubPlanner on January 08, 2016, 04:57:17 PM
 ;D

Worked like a charm, thanks so much.

Subplanner
Browser ID: smf (is_webkit)
Templates: 1: Printpage (default).
Sub templates: 4: init, print_above, main, print_below.
Language files: 1: index+Modifications.english (default).
Style sheets: 0: .
Hooks called: 47 (show)
Files included: 25 - 925KB. (show)
Memory used: 773KB.
Tokens: post-login.
Cache hits: 7: 0.00125s for 22,301 bytes (show)
Cache misses: 1: (show)
Queries used: 9.

[Show Queries]