Making a Macro available for any Visio document - macros

I want to create a number of macros and be able to use them in any Visio document. I know the rudiments of creating a macro with the "Record Macro function", but it appears that the macro so recorded is only available to that Visio file. I've searched to see how this could be done but have not had success on how to do so. Any assistance would be appreciated.

I'm assuming you mean you want to write code in a Visio document that calls code written in another Visio document. There are two ways I know of to do this with VBA.
The first is to use the ExecuteLine method on a Document object. You just pass in a line of VBA you want to call in that document as a string argument, and the code gets called. This is really only good for calling macros that take no arguments, or if they do, just string/number arguments.
The second way is to save your document (usually a vss* stencil file, if you provide template shapes with your macros), and in any other document you just set a reference to your code file. This allows the VB Editor to have intellisense and see all the methods you can call in your macro file, and makes it possible to pass whatever type of arguments that your methods can take.
Now, if you are only interested in invoking/calling simple methods in a central file through UI actions, there are many different ways to do this. You can assign code to different shapes, ie whenever that shape moves, or when it'd double clicked. This can be assigned in the ShapeSheet window for a shape in the Events section.
You can also draw command buttons or any other VBA controls right on a Visio page and assign your macros to those buttons.
Or you can go to Tools->Macros->(your document name) and there will be more dropdowns for each module in your code file, where you can call any public subs that have no arguments.
Or you can build a toolbar (in the pre-Visio 2010) or ribbon interface with buttons that call your code. Building a toolbar for a VBA solution is kinda crappy though, from my experience. A toolbar button has to call code contained in the document you want to have your code act on. So let's say you have your code all written and saved in a VSS file that, any time a new document is opened, calls a method that adds a toolbar for the new document. When you assign the code to the buttons on that toolbar, the toolbar is assuming the code you've assigned resides in the new document you've opened, not your VSS file. So, to make your buttons call your VSS file, you have to have a method in your new document that uses ExecuteLine to call your actual code in your VSS file. This is a pain, because now your user has to use a VST template file you provide, rather than, theoretically, use your tool on any drawing they want to.
Sorry for the rant, but Visio is pretty flexible in terms of how to call code, so you can probably do just about anything you want.

My solution is to save my macros in a stencil. As long as you have the stencil open, the code is available to the active drawing. Now, if I just figure out how to put "buttons" in the stencil to activate a specific macro...

Related

How to edit transformer as javascript script in Mirth (rather then as individual steps)?

How to edit transformer as javascript script in Mirth (3.10) (rather then as individual Mapper steps constrained by the building block UI)? I can see that the primary UI for each step is generating JS code and I'd like to play with that code directly (eg. have a single script that composites all of the JS Transformer logic). (Am totally new to using Mirth)
Eg. I want to set output message values as more complex values than those that can fit in a a single line of javascript available in the primary Transformer UI and be able to organize steps beyond continually clicking the "move step up/down" menu button.
The only thing I've seen so far as managing the Source Transformer on a more controlled level is exporting the XML (I'm assuming this is not how people are meant to interact/edit with the transformers).
I see the scripts tab in the main Channel UI, but IDK how to make that "connect" / act for the Source Transformer (scanned over the user manual, but was not able to figure this out yet).
Anyone with more experience know how to do this? Any links that could explain / show?
In a transformer, you can add a new step (right click in a blank space or with the menu in the left bar), then you can change the type of the new line to "JavaScript"
(screenshot here)
Then, the space in the bottom changes to a blank page where you can type your JavaScript code.

GUI: configure the racket:text% to read-only

I want to use an editor to display a log from a program, I just need a very basic text field:
With a vertical scrollbar
With a contextual menu for copy/paste
Prevent the user from changing the text
In order to activate the copy/paste menu, I use the class racket:text% from framework rather than the basic one.
How to prevent the user from changing the text?
I read the documentation, as far as I understand the closest thing I found is lock method:
https://docs.racket-lang.org/gui/editor___.html?q=lock#%28meth._%28%28%28lib._mred%2Fmain..rkt%29._editor~3c~25~3e%29._lock%29%29
But it is not convenient, as it also prevent my program to write the data.
I also find get-read-write? but cannot find set-read-write.
Use the lock method, and just unlock the editor around any modifications that you want to do. You may find it useful to write a call-with-unlock helper function or with-unlock macro.
If you do your updates from the eventspace's handler thread (and you probably should; use queue-callback if they originate from another thread), then as long as you re-lock the editor at the end of an update, the user will never be able to interact with the unlocked editor.

MS Access 2013 textbox update macro

What I am trying to accomplish:
Use button to open a form, filter the form, and set specific value to an unbound textbox in the opened form's header. There are multiple buttons being used open the same form and I would like this textbox to changed every time a specific button is clicked.
What I have done so far:
Used a macro to open the form and the "where" condition to filter the records. I also used "SetProperty" to change the value of the unbound textbox in the opened form's header depending on which button was clicked. When I do used the SetProperty option in the macro I get the error "The control name ... is misspelled or refers to a control that doesn't exist. Error 32004
I have verified numerous times that this is the correct name for the textbox and everything. I am pretty new to access and don't do VBA all that much so any assistance would be greatly appreciated. Thanks.
First Form and Macro for the "Physical Security" Button
Second form with error and unbound txt box I want to change to "Physical Security"
A few Ideas to track down your problem:
Maybe there's a problem with opening and (immediately) accessing the forms controls(?) You could try to fire a macro from within the same from that (only) changes the value of this text-box to make sure it definitely works there. Of course you'd want to make it work there if it failed before you'd go back to your original problem.
Is the property called value? Could it be text?
Are you sure you need to separate (all) hierarchies using !? Just by desperation: Maybe try using Forms!frmVW.txtXY or Forms.frmVW.txtXY
If that doesn't solve it:
It's often best to reduce your problem to it's very basics. Copy your application (!!!!) and radically delete unneeded stuff. Or start a short experiment from scratch (one or two forms, maybe only a button and a textbox, a macro, most probably not even a single Datatable/Source).

GWT Editors for readonly and edit mode

GWT's Editor framework is really handy and it can not only be used for editing POJOs but also for read-only display.
However I am not entirely sure what the best practice is for doing inline edits.
Let's assume I have a PersonProxy and I have one Presenter-View pair for displaying and editing the PersonProxy. This Presenter-View should by default display the PersonProxy in read-only mode and if the user presses on a edit button it should allow the user to edit the PersonProxy object.
The solution I came up with was to create two Editors (PersonEditEditor and PersonDisplayEditor) that both added via UiBinder to the View. The PersonEditEditor contains
ValueBoxEditorDecorators and the PersonDisplayEditor contains normal Labels.
Initially I display the PersonDisplayEditor and hide PersonEditEditor.
In the View I create two RequestFactoryEditorDriver for each Editor and make it accessable from the Presenter via the View interface. I also define a setState() method in the View interface.
When the Presenter is displayed for the first time I call PersonDisplayDriver.display() and setState(DISPLAYING).
When the user clicks on the Edit button I call PersonEditDriver.edit() and setState(EDITING) from my Presenter.
setState(EDITING) will hide the PersonDisplayEditor and make the PersonEditEditor visible.
I am not sure if this is the best approach. If not what's the recommended approach for doing inline edits? What's the best way to do unit-testing on the Editors?
If you can afford developing 2 distinct views, then go with it, it gives you the most flexibility.
What we did in our app, where we couldn't afford the cost of developing and maintaining two views, was to bake the two states down into our editors, e.g. a custom component that can be either a label or a text box (in most cases, we simply set the text box to read-only and applied some styling to hide the box borders).
To detect which mode we're in, because we use RequestFactoryEditorDriver (like you do), we have our editors implement HasRequestContext: receiving a null value here means the driver's display() method was used, so we're in read-only mode. An alternative would be to use an EditorVisitor along with some HasReadOnly interface (which BTW is exactly what RequestFactoryEditorDriver does to pass the RequestContext down to HasRequestContext editors).
Yes,Presenter-View pair should be. But Here two ways to achieve this feature if you like to go with:
1) Integrate Edit/View code design in one ui.xml i.e.Edit code in EDitHorizonatlPanel and View code in ViewHorizontalPanel.The panel has different id. By using id, show/hide panel with display method. if getView().setState() ==Displaying then show ViewHorizontalPanel and if getView().setState()==Editing then show EditHorizontalPanel.
2) Instead of using labels, Use textboxes only. set Enable property is false when you need it in view mode otherwise true
You have created two Presenter/view but I think if Edit/View function has similar code so no need to rewrite similar code again and again for view purpose.
If a big project has so many Edit/View function and you will create such type of multiple View/Presenter than your project size become so huge unnecessary.
I think that whatever I have suggest that might be not good approach but a way should be find out which help to avoid code replication.

jQuery Show/Hide divs using same class not working because of html.push?

The object is to Show-Hide text located under their respective Titles, so a User reads the title and shows or hides text belonging to that title if the User wants to read more.
I tried whatever I could find so far on here, we're talking dynamically setting text coming from a spreadsheet, can't use IDs, must work with .class, must be missing something, I have this piece of code:
... html.push('<div class="comments">' + comment + '</div></div></div>');
but when I try this Show-Hide code nothing happens, even if the error console shows nothing. Basically I want to Show-Hide the .comments class divs with a show-hide toggle link located under each of them. I say them because the .comments divs are reproduced dynamically while extracting text coming from Google spreadsheet cells/row (one .comments div per spreadsheet row). I tried .next, child and parent but they all divorced me so I dunno looks like a dynamic issue. So far I only managed to globally toggle all divs to a visible or hidden state but I need to toggle independantly individual divs.
I prefer a jQuery solution but whatever worked so far was achieved with native javascript.
Note: If a cross-browser truncate function which would append a more-less link after a number of words (var) in each .comments divs would be easier to implement then I would gladly take that option. Thx for any help, remember I am still learning lol!
I have been working on an entirely JS UI project and have brought myself to using $('', { properties }).appendTo(BaseElement) to work best for adding HTML elements because it appropriately manipulates the DOM every time.
If you are having good luck with push elsewhere, however, breakpointing on the line where you do your $('.class').hide() and see what $('.class').length is. Alternately, you can just add alert($('.class').length) to your code if you are unable to breakpoint the code. If it is 0, then your elements have not been properly added to the DOM. Changing to append will ensure they are part of the DOM and therefore targetable via JQuery.