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

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.

Related

Manipulate the MS-Word Navigation Pane via VBA-Macro [duplicate]

I am trying to write a VBA macro that runs when opening a .docx document. I want it to force the display of the Navigation Pane and then force all of the headings (any level) to display in collapsed mode. I am trying to get the code for the Collapse command using the macro recorder.
All I have when I record the macro is:
ActiveWindow.DocumentMap = True
Right-clicking on a heading in the Navigation Pane and collapsing does not record a code line. Is there a VBA method for this event?
I "solved" this requirement for myself by means of an AutoHotKey script, which just sends the necessary mouse click and subsequent key strokes. Not beautiful, but it works most of the times.
Kind regards, Hauke
As of this writing in 2019, this is not possible through VBA. It's been asked for from Microsoft for a long time.
As originally suggested in this Microsoft forum post, the quickest way to collapse all of the headings in the Navigation pane is to right-click one of the headings and click Collapse All. Obviously this is not an automated/macro-based solution, but it's all we have until Microsoft exposes the task panes through the VBA object model.

Microsoft Word - How to add a button to insert file

I want to add a button in microsoft word that when I click it opens microsoft explorer to insert a file in the word page.
I already have the button but dont know what action should i do to implement that.
Any help?
You could, instead of adding a Button in your document, add the Insert File command to the QAT for that document.
This is a bit more subtle but works in non-macro enabled documents. In my opinion it is much easier to do.
You would want to draw your user's attention to it. Many places will not allow macros to run. It may run on Macs, which will not work with your ActiveX button. Here is my webpage on Modifying the QAT.

Embedding Word Object into VB.Net Winform

I wondering if its possible to use Microsoft Word as a text editor in a VB.Net project?
My project currently uses a Rich Text Box to allow the user to right a report which is then saved and a report generated. I was wondering if i could switch to Word for better formatting and layout options, be it embedded in the actual form or in another form thats called (if that makes it easier to assign the control).
I have worked on opening Word itself via a button click but would like to have it incorporated in the project. All users that would actually use the program would have one of the more recent versions of word installed.
Any pointers to websites would be great as i'm constantly searching but not getting very far
Thanks

Can I base a word template on another template

For the purposes of branding, our Word normal.dot template is updated via the login script. This pains me terribly, because I have a number of very useful VBA macros that I want to have access to. Specifically, I have two macros that I add to the Quick Access Toolbar in the title bar that I use all the time.
From what I understand, those macros can only be taken from the document itself or from the template it is based on.
What I am looking for, is a way to either:
Add a QAT button to a macro in another file somewhere.
Base all my documents on a new template (call it abnormal.dot) which in turn is based on normal.dot, so it can retain the macros even when normal.dot is overwritten.
Any other way of achieving my goal.
Any ideas?
You can add additional templates to your Word Application.
Go to Developer Tab on the Ribbon >> Templates section >> press Document Templates...
In new window on Template page you will find Add button on the right- add there some additional templates. This should help.

How to assign themes and Quickstyles in Word VBA

Where I work a department has created several theme files and quickstyle colours they want used in different circumstances.
I am wanting to create a macro that when run would save the theme automatically, and then assign a quickstyle colour group.
I have tried the macro recorder does not provide any hints as the macro is blank after attempting to record the actions, this is using either the mouse or keyboard. Searched everwhere and no solutions.
I can create the ribbon tab and buttons where we will call the macros from, I have already created macros and forms to populate documents with addresses etc.
But I cannot find any where I can set and save a theme or quick style and or colours.
A good idea for VBA is always to look into the Object Explorer in the IDE. Just press F2 while in the VBA Editor and type in the search field "theme".
There are the methods ActiveDocument.ApplyDocumentTheme(Filename as string) and ActiveDocument.ApplyTheme(Name as string). For quick styles you'll find also methods.
I don't have the time to test it, but I guess here you can go on.