spreadsheetgear+how to display built in page setup dialog - vb.net

I tried to select/display the builtin pagesetup dialog highlighting the pagesetup tab in 'spreadsheetgear workbook explorer' window. In the .exe provided by spreadsheetgear, it is shown but not in the sample code provided by them, can anyone from the expert group who uses the spreadsheetgear advice me how to select the specific tab in the workbook explorer of spreadsheetgear through code.

If you are trying to pre-select a particular "Page Setup" node for a particular worksheet in the TreeView of the Workbook Explorer dialog when you instantiate this dialog yourself, i.e., something like...
WorkbookExplorer explorerDialog = new WorkbookExplorer(workbookView.ActiveWorkbookSet);
//explorerDialog.SelectPageSetupNode(...); // This API doesn't exist.
explorerDialog.Show();
...then this is not possible, as there are no public APIs to do this.
The SpreadsheetGear2017ForWindows.exe application can do this because it has access to internal APIs to make such a selection. We do collect feature requests to expose public APIs to perform such tasks (I work for SpreadsheetGear), so I can add one for you, although I cannot comment on if or when such a feature would be added to our product.

Related

Call Word Menu-Button in VBA?

everyone,
I am new to VBA and would like to know if it is possible to execute a menu button from a WordAddIn.
In the picture you can see which button I would like to execute using VBA.
Unfortunately, I can't record it via macro.
The Word object model allows executing built-in ribbon controls using the CommandBars.ExecuteMso method which executes the control identified by the idMso parameter. This method is useful in cases where there is no object model for a particular command. Works on controls that are built-in buttons, toggleButtons, and splitButtons.
But in your case the control comes from a third-party add-in which doesn't expose IDs and the CommandBars.ExecuteMso method can't find it and invoke the command programmatically.
To get the job done you may consider using the Microsoft Active Accessibility which is a Component Object Model (COM)-based technology that improves the way accessibility aids work with applications running on Microsoft Windows. It provides dynamic-link libraries that are incorporated into the operating system as well as a COM interface and API elements that provide reliable methods for exposing information about UI elements.
Also you may contact the add-in vendor for providing public methods that can be called from your solution. That's also a possible workaround instead of calling UI elements on the ribbon.

Late binding object to existing instance via handle in VBA

This question pertains to VBA Internet Explorer automation
What I have is an Internet Explorer window that loads a dialog box with buttons when the page loads.
Here are the givens:
The dialog box is of the "Internet Explorer_TridentDlgFrame" class
It isn't considered an app window like its originating IE window.
Its "form" and button "ID's are obtainable but not within DOM of the originating IE document
So, referencing said IDs to interact with them does not work.
Similarly, injecting JavaScript attached to its buttons does not work
The dialog box can't be bypassed by closing it. A "continue" button must be pressed.
So I figured I'd use another method:
If I cycle through all windows, I can obtain the dialog box's window handle via its window title.
With that said, is there a way to late-bind "Object A" to the dialog box's window via handle?
And if so, is it then possible to late-bind "Object B" to "Object A's" document/form in order to interact with it?
This would be like accessing an existing instance of an open Excel workbook and late binding an object to it in order to interact with the workbook itself.
Note: I have used Selenium in the past, and while it may be a better solution to get around this dialog box, translating the rest of my (already) written program into Java would be a nightmare.
Note2: Using winHttp or other "headless" methods isn't an option
Any help is appreciated! Thanks!

Centralized VBA code for multiple Word files

I have multiple files with the same VBA code in them, which will most likely have to be changed over time. I don't want to go one by one and c/p the code, so one obvious idea that came to mind is to have one centralized document with the code (template?) that all files refer to.
I found a few topics here at stackoverflow, but none of them work for me or are inconclusive:
Run external vba-code in MS Word
Centralized VBA code (one file) for multiple workbooks
Calling an External VBA from VBScript
Any ideas?
Yes, your idea of centralizing the code in a template and attaching that template to the various Word docs will work. These pics are using Word 2007 but I think it's pretty similar for newer versions. First create a new document and put the code in a Module (named "CommonFunctions" in the picture):
Save the doc as a macro-enabled template:
Now make a new document, save it as a *.docm (necessary for it to run code because a *.docx is macro-free), and attach the document template as shown below. (An alternative is to put the *.dotm file in the startup directory C:\Users\<username>\AppData\Roaming\Microsoft\Word\STARTUP, which loads it automatically.) If you don't put it in the Startup, you'll see the name but it won't be loaded (ie, checked), but you can load it in code, as I'll show.
Make a user form in this document:
Put this code for the button's click event:
If AddIns("c:\_b\MasterDocWithFunctions.dotm").Installed = False Then
AddIns("c:\_b\MasterDocWithFunctions.dotm").Installed = True
End If
Application.Run "CommonFunctions.Test1"
Application.Run "CommonFunctions.Test2"
Notice how the code can load the AddIn for you, because it won't be automatically loaded unless you put it in the Startup directory. This pic shows how the AddIn is referenced but not loaded. You need the checkbox to be able to call code in it. If you don't load it using code and don't put it in the Startup, then the user will have to manually put a checkmark everytime the document opens.
Now the form should work when you click the button. Notice how it can call both public and private functions. The Private keyword definitely shields one module from another, but it seems like modules that are called from an AddIn are considered to be part of the same module, not sure why? Also if you don't put Public or Private at all then VBA considers it Public, I'm pretty sure.

Please let me know feasibility using Excel and VBA programming and suggest solution approach

We have following requirement to be done via excel and VBA programming. Please check and let me know if it feasible to do so and if not what way would be best to do it.
There would be excel spreadsheet say excel 2007/2010 with 2 tabs.
1st tab contains normal excel data
In 2nd tab user can enter a particular value and then click on a button in same tab. Is it possibly to have a button in excel tab and can it raise events like windows/web applications?
Now if button can be kept in excel and it can raise button click event then on such an event we need to create xml files. Is it possible to create xml files adhering to schema using excel &/or VBA programming
You need to activate the developer tab (from backstage go to Options and check the visibility of this tab) to get access to normal windows controls, like buttons and drop-down lists etc. You can easily place those in Excel sheets and write event handlers: the controls support the full range of events, including OnClick, OnMouseEnter etc...
You can write custom text files directly from VBA, but you can't validate those. The usual way to do so is just to concatenate small XML blocks into a bigger file, so XML output is more like a normal text output. But it works fine and as long as you do not need to perform something really complicated it is also ok.
EDIT: You can easily add references to custom COM objects (.dll or .ocx) and use them directly in your VBA code. One very helpful suggestion (see the comment below) is to use the MS XML library.
To add a reference just open the code editor (Alt + F11) and then go to Options -> References. Most of the references you need will be already in the list and you just have to check them, but you can also add your own custom libraries by clicking on Browse.

Modify Outlook Form Code programmatically

How to programmatically get at outlook form code?
To clarify from one of the comments - Outlook form code is the VBA code that sits behind the form - it can be customised in the form design mode to do pretty much what the user needs to do.
Our product relies heavily on form code, but certain bits of it need to be customised per installation. We are looking for some way to automate this process, as we have upwards of 30 custom forms it is a tedious process to do it manually...:-)
Use a configuration file (use ReadFile etc)
Or put the configuration information in a "special" item in a public shared folder
You can also use the "Office Profile Wizard" to package it up with a custom vba module iwht the configuration information in that
You should never write out customised code, that is a big can of worms