How do I launch a Word VBA Application from a Form (not a document)? - vba

I created a Word Application using VBA. At present, I launch it from the IDE associated with a particular document. When my app launches, I click a Command Button on a Form to begin processing my data.
Question: How do I launch this application directly from the Form? Perhaps I can fashion my Word document to look like my Form.

If you don't need a form to collect information from the user, you can run macros directly from Word. Go to the View Ribbon tab and click the Macros button on the far right (or press Alt-F8).

Related

Make a VBA form appear in windows task bar

I am programming a little application (an overgrown macro really) in Visual Basic for Applications in Office 365. What it does is:
Displays one window that has a few input fields.
Once I fill out those fields with data I can press a button on the form and a summary in a nice graphical form is displayed in a second window (a second form is displayed using UserForm2.show).
The second user form can be updated with new data by typing in updated text in first form and updating the second form by pressing a button on the first form (in the form of UserForm2.TextField1.Text = UserForm1.Label1.Text.
Both forms are modeless so the user can work in Outlook whilst the forms are running.
All works fine except one caveat:
Both forms are not visible on the Windows Taskbar, in the Task Manager, but most importantly they are not visible as separate windows to teleconferencing software we are using. And this is the macro's sole purpose.
Question: Is it possible to make the entire macro (or just UserForm2) run as if it was a separate application, so it appears in the Task Bar as a separate window, and not an internal form running inside Outlook?
The idea is not to run it independently of Outlook (or Excel), but to make them visible to external programs.
I tried a few options available on the Internet, but none of them work, and honestly I do not know where to begin, or how to circumvent it if it is not possible to do directly within the available API. Can you advise?

How do I make a userform appear on demand in Microsoft Word?

I can make it popup on opening the document, but what if I close the userform and want to it to show up again in the same document? I know in excel you can add a button onto a worksheet directly and make it show the userform on click, but this button is unavailable for microsoft Word. Is there a solution besides initiating the script by hand?
To display a VBA userform, you can trigger it from a macrobutton field, from a form field, from a shape, from a QAT button or from an ActiveX button. There are probably a couple of other methods I'm not remembering at the moment. Each is a little different in the exact steps, but all will run the command:
UserFormName.Show

How to programmatically add a button to my windows form, which will open a macro on click?

I have a macro file. I want to add a button in a windows form of my application, on click of which this macro file will open, so that the user can run the macro by themselves. Has anybody come across similar coding scenario who can guide with some code? I am using vb.net.
Button1_Click
Process.Start(Macro Location)
If you can compile the macro, you can run it as an exe, so you don't have to boot the IDE to run it.

How to add button to word 2007 document, and handle click event with VBA?

How do I:
add button to my ms word 2007 document (i would say this would be trivial task, but can't even figure THIS out)
handle click event of this button in my VBA script
set text of my text control (with tag "text1")
I don't know if it is what you intended, but to add a button in the document, open the Developer tab. Click the Legacy tools folder (in the Controls group) and click the Command Button (Active X Control). This will put a button in the document and make Word go into design mode.
Double-click the new button and you will enter the VBA editor in the event handler for the button.
Enter code to manipulate the text in TextBox1:
TextBox1.Text = "Hi there, VBA master!"
Click the design mode button to exit design mode, and you're good to go; click the new button to set the text.
If you meant to add a button in the ribbon? A little more complicated, but not that hard. Leave a comment, and I'm sure we can work it out as well.

In Excel, is there a way to determine the method being called by a password protected 3rd-party ribbon button?

I'm looking to automate a simple process in VBA and need to "click" a ribbon button. It makes the most sense to just call the button's underlying method. Is there a way to figure out what it is?
We are using Excel 2007 and 2010.
If it's Excel 2003 or earlier, you can use the CommandbarControl.Execute method. For instance:
Application.Commandbars("3rd Party Toolbar").Controls("Button to Push").Execute
There are two ways you can do this.
Right click on the toolbar and select Customise. If you right click on the button there may be details somewhere of what Macro the button is associated with.
If you record a macro and click the button. Then you can look at the VBA workspace and view the code that is generated to run your macro (which is just clicking the button you want). This will show you what method the macro clicks.