Is it possible to programmatically change the selected master within a specific stencil document in Visio, using VBA? If so, how would I go about doing it?
It doesn't seem possible to use the Window.Select method, since that seems to only work in the drawing page...
With Visio API only it is only possible to get selected master(s) using the Window.SelectedMasters property, but not set it (it is a readonly property).
So, there is no direct solution.
If you are okay with (sort of) workaround, you can take a look at mine here (the same question):
http://visguy.com/vgforum/index.php?topic=3378.msg13172#msg13172
It simply sends keyboard keys to the stencil window right number of times :)
Related
I refer specifically to the 2016 version, but this should also apply to 2013 and 2010.
----- TLDR Summary
Is it possible to use VBA to add a new Slide Master using a method
that I haven't found?
Is it possible to use VBA to access or manipulate the Layouts of
Slide Masters other than the first one in a Presentation object?
I suspect that the answer to both is "No" and that MS has merely
screwed up the exposure of the underlying objects, but others may
know more about programming PPT than me.
------ The Whole Question
Microsoft has deemed PowerPoint unworthy of a macro recorder for lo these many versions (I think it was dropped in either 2003 or 2007 from memory), so no help can be obtained from there.
The linked MSDN "help" item is woeful. It states that the property returns a Master object, though that isn't relevant for the moment.
An Office support page describes a slide master here. A Slide Master seems to be where the presentation's Slide Layouts live, presumably in the SlideMaster's CustomLayouts property, though it's interesting to note that only the first 9 of those CustomLayouts correspond to what you see in the GUI. (I count 11 CustomLayout objects in the SlideMaster in a new, blank presentation.) The numbers change if you add new layouts though the two vertical text layouts never seem to appear in the GUI list. This too is not the problem.
The problem is that you can in fact have more than one Slide Master per presentation by going to the View menu, Slide Master, and then selecting Insert Slide Master. Having multiple Slide Masters is discussed on the Office Support site here.
Frankly I regard this functionality as slightly broken because if you do that, then apply a Theme to the new Slide Master, you end up with a third Slide Master; the original under "Office Theme", a second under "Custom Design", and a third under the name of the Theme that you applied. This too is not in itself a problem. (Though it's worth noting that a Presentation does not have an AddSlideMaster method, which means that it does not seem to be possible to do this by VBA. Not that you necessarily want to, but if you did, you can't. There is only an .AddTitleMaster method which seems to be useless since all presentations have a TitleMaster as far as I can see and if a presentation has one then that method will error out according to the documentation.)
The problem is that the Presentation object does not have a collection of Slide Masters. It has only that one property, SlideMaster, which returns a single Slide Master / Master object.
Accordingly I can't see any way that you can programmatically add a new Slide Master. And even if you used one that is added through the GUI you can't seem to access any Slide Master except for the first one. And therefore you don't seem to be able to access, manipulate or assign any Layout from any Slide Master other than the first one to an individual slide.
Am I correct in this assumption, or am I missing something?
I shall offer thanks in advance even though that is often deleted from questions. Not that this one is likely to attract much attention; I suspect that there may be another Tumbleweed badge in my future.
Perhaps this page will be helpful in understanding it better - http://skp.mvps.org/2007/ppt003.htm
I made a VBA-Macro, activated via a Ribbon-Button for exporting selected Mails into a certain folder.
I'd like to make this Macro available in Word and Excel (for exporting doc/xls) into the same folder-structure.
Is it possible to check for the active application and then decide if a Mail(s)-Export or a simple Doc/Xls-Export should be done?
If you are working with multiple Applications probably the easiest way to identify one would be to use Application.Name property.
If you happen to have passed an object of some type that has the .Application property you can also call that. Refer to this post for details.
Also, with most MS-Office objects you can go up the hierarchy using the .Parent property to get all the way up to the Application, ie. .someObj.Parent.Parent.Parent.Application.Name
We are trying to save some additional information with a document using the QuerySaveDocument event. However it seems that it is not being triggered at all.
<xp:executeScript script="#{javascript:setField(document1, 'cCustAddr1_fi', 'test');}">
</xp:executeScript>
This is our basic script. All the setField() method does is use replaceItemValue to try and set the field. However it seems that QuerySaveDocument is not even being triggered since we can write pretty much anything and the document will still save without problem, even if it would be impossible to execute.
We have also tried using a simple document1.getDocument().replaceItemValue() script, but again I dont think it even attempts to execute. Our documents save perfectly fine too,
Do you see any reason for this, are we doing our saving wrong, or should we be attaching data onto the document in another way?
Thanks.
Your other question on Unplugged (Using other dialog controls in iOS) suggests that you are using the Unplugged Mobile Controls project.
If that is correct then my comment above applies - the querySaveDocument event won't get fired . You can look at the code in UnpSaveDocument.xsp and possibly add your own SSJS code to that.
Alternatively, if you want an additional item created on your back-end Notes document then you should just be able to add a hidden field to the UnpFormEditor that is bound to the document1 data source and using the relevant item name you want.
I have 20 or so grids in my application suite. I'd like to create a global copy/paste context menu which I can bind to every single grid rather than code in each form.
I am unsure what is the best way to achieve this, I have started to create a class with my menu in it, but get stuck at the point of adding the actual menu options. For example I know I'll need to call a "copy" event, but I also know I'll need to tell it what I am copying, and I cannot see how that is done in vb.net when you can only add the address of a method minus parameters.
e.g.
.MenuItems.Add("Copy Cell", New System.EventHandler(AddressOf CopyCell))
Obviously I want "CopyCell" to only be coded in one place as well, rather than repeated in each form. I will always be copying the same object (SelectedCellCollection).
I am not sure how to make the menu have an event with parameters, or how to make it "know" that I want to always copy the selected items. I'm aware that I'd have to do some coding in the form but just trying to work out the way to minimize it.
I have created my own context menu class (via inheritance) with specific copy and paste functionality / options tailored to the grid I am using. It works fine and only needs one line of code per form/grid to activate.
I need to update an Access VBA app with around 30 forms in it.
I have to amend a screen that seems to have been set up right at the start of the app, it uses a lot of SQL tables. Is there an way of finding my way to the start of the code?
I come from a procedural coding background and I am unused to code that doesn't have a start and an end; I also know a bit of VB, some ASP, some .Net and general computing.
When something "automagically" happens upon opening an Access database, it is almost always because
A "startup form" has been specified. (In Access_2010 that's done in File > Options > Current Database > Display Form.) ...or...
The database has a Macro named AutoExec which is automatically run when the database is opened (unless you bypass it by holding the [Shift] key down while opening).
In addition to #Gord's answer, there's a few things you need to know. I'm going to give you the quick & dirty version.
First, there's 2 types of code in Access. VBA & macros. Sometimes what's called a macro, is really VBA.
In Access, a macro is a set of instructions to do something to the database. It's very limited in what it can do. These are often used by novices who don't know how to program in VBA.
VBA is the real powerhouse behind the scenes. It can do everything a macro can do, but a whole lot more.
Access uses an Event-Driven / Object-Oriented (at least close enough for this discussion) interface. Do a Google search on those meanings. But very quickly, the listbox on a form is an object. It has properties (like width), methods (add an item), and events (click on an item).
To see the code, for macros look to to your navigation window to your left. For VBA (modules), look to the same window, or just press Alt-F11. VBA can be used standalone in a module, or behind the scenes of a form or report.
Once you get the hang of it, you'll find Access to be a handy RAD tool for small projects.
Good luck.
It appears that you already have found the form that opens when the app starts (if not, check out Gord Thompson's answer).
The first things that happen when an Access Form opens (the "start of the code", as you called it) are the Load and Open events.
If there is any code in this form that is connected to these events, then it's in the Form_Load() and Form_Open() functions in the code of the form.