vba excel userform preview print - excel

Is it possible to preview print a user from in vba excel or print the user form to a place in a worksheet?
I already know this
UserForm1.PrintForm

Here is the answer.
It is not possible to display a Print Preview of a userform using only VBA.
It is possible to do so using a series of Wind32 APIs, as the userform is a Window. However, this is not trivial and requires a lot of code.

Related

VBA Userform Combobox not populating on open

It been a while since I built a userform in Excel, so forgive me if this is something obvious. I have a userform containing a number of comboboxes. On opening the workbook, I populate them all with a list of reports stored in SQL, using the Workbook_Open macro.
However, when I close the userform and then reopen it, the comboboxes are empty. I that the way userforms work? Do you need to populate these boxes each time you launch the userform? I'm happy to do this but just wanted to check in case I'm missing a setting or a simple line of code.
Thanks

Most User Friendly Way to use a VBA EXCEL Userform?

So I have programmed several userform with several user inputs(text boxes, check boxes, etc.) Now how can I use them outside of excel?
Currently I have to:
Open up the spreadsheet
Enable macros
Go to Developer Tab, View Code
Then find the right userform and run it or type F5.
Is there a more user-friendly way to run the userform? Its for testers who don't know vba or excel programming.
Thanks!
Yes, absolutely. You could create a button named after the form in question, and to that button assign the following macro:
Sub btn1()
frm1.Show
End sub
That's it! Of course, change the names according to what you have :)
I also reccomend having a button to close the form on the form itself.
OF COURSE this still uses Excel. If you want to use them on their own you could have something like this guy did: How to Open only UserForm of an excel macro from batch file

Creating a button on Excel Ribbon to open Userform Window

I have developed a VBA userform interface that allows the user to input values, have it calculate results, and then print them out into the worksheet. I am wondering if there is any possible way that I can have a button on the excel ribbon, say under the "Data" tab for instance, that would elicit the userform interface to open.
Currently the only way I can use the interface is by Developer>>Visual Basic>>Clicking on Userform>>F5. This also limits the userform in that it can only be used in one particular workbook as opposed to many. Or if it was somehow possible, to make it an add-in instead.
Any help is greatly appreciated!
The easiest way to add custom tab and/or button to Ribbon is to use Custom UI Editor Tool for MS Office Ribbon. Follow the links provided in comments to your question too. There you'll find many useful information.

Excel 2007 Combo Box - Developer Ribbon vs. VBA Module

Could someone please explain to me the difference between the combo box that's available via the Developer Ribbon in Excel 2007 vs. the Combo Box control that's in the VBA editor? I cannot get this simple line of code to work using the Developer combo box:
MsgBox Combo1.Value
I've tied it to the change event and it seems to be syntactically correct (I'm not a VBA coder by any stretch).
Is the Developer Ribbon version some bastardized craptastic Microsoft shortcut?
What I'm trying to do is populate a second combo box based on the selection of the first combo box. I'd rather not build a case statement for every possible selection. Is this possible using the Developer ribbon version?
You are talking about the Insert button on the Developer tab correct? From that button you can add an ActiveX control or Form control. You're better off using the form controls if your new to programming as they will behave more in line with any Excel VBA reading you've done and the help file. With the Form controls you can right click and choose 'View Code' and/or 'Rename Control and Code'. Renaming the control allows you to address it in VBA however you like. e.g. - Combo1.value or myFavoriteCombo.value
That being said, to answer your question directly, be sure you know the controls full name. If you used a form control and it was the first one you put on the sheet it will be named ComboBox1. To get to the combobox's properties you have to walk through it's 'parent' sheet.
i.e.
MsgBox Sheet1.ComboBox1.value (using the sheet's code name)
or
MsgBox Worksheets("SheetName").ComboBox1.value (using the sheets name as it appears on the Excel tab)

How do I add a form in an Excel sheet?

How can I add an input form in an Excel sheet. I want to insert values into an Excel cell using the form.
ALT+F11 starts the VBA editor in Excel. In there you can create UserForms (Insert | UserForm) which you can bind into their own modules or attach to worksheets.
I suggest you look at the Excel help or MSDN for details of what you can do with UserForms. There are also a lot of VBA tutorials on the web for exactly this sort of thing. Google is your friend.
HTH
There is a quick and dirty method of creating simple forms in Excel. No VBA is required.
First, create a table with the basic format that you want.
E.g.
A B C
1 Name Age Favourite Animal
2 Jane 11 Horse
Select the range, and then select Data | Form. (This is in Excel 2003.)
It will open up a simple form that allows navigation, creation, deletion, and searching.
#Oddthinking,
Cool trick. Never knew it existed. I had to do a little looking, but you can do it in Excel 2007 as well.
Click the Office button, select Excel Options, go to the Customize tab
Select 'Commands Not in the Ribbon' from the 'Choose commands from' drop down
Find 'Form' in the list and click Add, then click OK
At this point, the Forms command will show up on the Quick Access toolbar, next to the Save and Undo/Redo icons.
You have to activate the form toolbar.
Of course, IIRC, the form must be handled by VBA code.

Resources