Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Office > Visio

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 06-13-2018, 02:17 AM
Dwids Dwids is offline Windows 10 Office 2016
Novice
 
Join Date: Apr 2018
Posts: 9
Dwids is on a distinguished road
Default Page.SetTheme Method example VBA?

I've inherited a number of multi-page Visio files and want to get them all to use the same Theme (and variations).

From the Shape Sheet from the 'one I wish to use as a reference' I can see the Page's "ThemeIndex" value (number) etc. But just can't get it/them to properly apply to a 2nd Visio file, via the Page.SetTheme Method in a VBA macro.

PagObj.SetTheme (35) works . It adds the space before the (). Mmm.


PagObj.SetTheme (35,2) gets a compile error; syntax error. This is what I want to use

(Yes I'm new to Visio VBA)

Thanks
Reply With Quote
  #2  
Old 06-13-2018, 07:40 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 737
Guessed is on a distinguished road
Default

Visio's VBA is a whole lot of confusion. But recording a macro gives you a few clues to get it working
Code:
  Dim aPage As Visio.Page
  For Each aPage In ActiveDocument.Pages
    aPage.SetTheme 35
    aPage.SetThemeVariant 2, 2
  Next aPage
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 06-13-2018, 08:12 PM
Dwids Dwids is offline Windows 10 Office 2016
Novice
 
Join Date: Apr 2018
Posts: 9
Dwids is on a distinguished road
Default

Hi Andrew,
Wow, thanks very much, that worked. I had tried to record a Macro, but was over-thinking it and recording it whilst editing the Page's Shape Sheet values. It is confusing as the MS website has the brackets (), like a function.
Code:
expression . SetTheme(varThemeIndex,varColorScheme,varEffectScheme,varConnectorScheme,varFontScheme)
expression A variable that represents a Page object.
Did I mis-read it?? Thanks again. I'm in Melbourne too
Reply With Quote
  #4  
Old 06-13-2018, 09:08 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 737
Guessed is on a distinguished road
Default

No you read it correctly but as I said, Visio's VBA doesn't make a great deal of sense. When I recorded it saved the theme as
.SetTheme 35, 35, 35, 35, 35
which is plainly stupid but most of those variables are optional so I removed them to make it simpler

In VBA, the brackets are optional unless you are trying to set a variable at the same time eg
Set aDoc = Documents.Add(sPath)
vs
Documents.Add sPath
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting method Steve Bartko Excel 6 10-26-2016 11:38 AM
Why no 'SaveCopyAs' method? Cosmo Word VBA 4 10-18-2013 05:57 AM
Creating a sorting method. Balliol Word 2 07-25-2013 06:18 AM
Shared Contacts & Calendars. Best method crobertson Outlook 1 05-08-2009 05:47 AM
Retrict Method Condition markp Outlook 0 12-22-2005 05:38 PM


All times are GMT -7. The time now is 01:34 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft