userform

VBA MSFORMS vs Controls - whats the difference

不打扰是莪最后的温柔 提交于 2019-12-30 09:51:09
问题 When adding controls to a userform, what is the difference between the following. I am confused as to when it is appropriate to use any particular one of these. Dim aButton1 as MSFORMS.CommandButton Dim aButton2 as Control.CommandButton Dim aButton3 as CommandButton 回答1: Add UserForm first . Then in VBA IDE press F2 , the object browser appears. In the upper left corner is combo box, select MSForms . In the classes list you can see the classes which belongs to MSForms object library. You can

Why can't I `End` code while I'm subclassing without breaking everything?

五迷三道 提交于 2019-12-30 03:18:05
问题 I've written some code in VBA to subclass a userform so that ultimately I can intercept WM_TIMER messages being dispatched to it. I'm doing this instead of specifying a TIMERPROC, as it allows me to use VBAs own error handling and calling methods to run callback functions. I'm using a userform rather than Application.hWnd because: I don't have to filter for my vs Excel/the host application's messages There are far too many messages going through Application.hWnd to be able to subclass it in a

Word Userform won't open in second, currently active document after opened/unloaded in first document

江枫思渺然 提交于 2019-12-25 18:36:40
问题 The headline really says it all, but here's my situation: I have a userform set up to collect user input, then uses that input in a macro and executes it. That, in itself, works exactly like I want it to. The problem comes when more than one document is open. To illustrate: I have two documents, 'doc a' and 'doc b'. I open both documents, then select 'doc a', open the userform using a show userform macro, input my data, and hit either 'Okay' or 'Cancel' (both of which are set to unload the

Returning a value or Cancel from Excel userform

二次信任 提交于 2019-12-25 16:25:12
问题 I have a sub that calls a userform to show and would only like to proceed if the user didn't click my Cancel button. I don't want to put all my other sub calls within the userform. Is it possible to have a userform return a value or a way to check if the user clicked a particular button? I suppose I can use a global variable, but was wondering if I could pass things to and from a userform. 回答1: I prefer to use properties. Inside your userForm Private m_bCancel As Boolean Public Property Get

Returning a value or Cancel from Excel userform

巧了我就是萌 提交于 2019-12-25 16:25:12
问题 I have a sub that calls a userform to show and would only like to proceed if the user didn't click my Cancel button. I don't want to put all my other sub calls within the userform. Is it possible to have a userform return a value or a way to check if the user clicked a particular button? I suppose I can use a global variable, but was wondering if I could pass things to and from a userform. 回答1: I prefer to use properties. Inside your userForm Private m_bCancel As Boolean Public Property Get

How do I reference the checkbox of the userform with a variable

五迷三道 提交于 2019-12-25 09:49:06
问题 Could anyone tell me how to reference a checkbox of the userform with a variable? For example I have something like these, if UserForm1.checkbox1.Value if UserForm1.checkbox2.Value if UserForm1.checkbox3.Value I have to check nearly 40 to 50 checkboxes. But writing the 40 to 50 statements like these is time consuming and also makes a bigger code. So I was kinda thinking to loop through them: For i = 1 To 50 UserForm1.checkbox & i .Value Next i Something like that. I didn't find too much but I

retrieving data from multiple textboxes created during runtime in an Excel userform using vba

浪子不回头ぞ 提交于 2019-12-25 09:44:24
问题 Okay...so I got some great help resolving my issue with adding multiple labels and textboxes to an Excel userform during runtime using vba. Now, the issue is I'm trying to retrieve data from those dynamically created textboxes. It's not that I can't get the data, it's that I can't pull it out of the form and use it once the form is closed. I used the following code sets for retrieving data from a single option textbox and it works perfectly: Private Sub SOSubmitButton_Click() FLNAmt =

retrieving data from multiple textboxes created during runtime in an Excel userform using vba

耗尽温柔 提交于 2019-12-25 09:44:01
问题 Okay...so I got some great help resolving my issue with adding multiple labels and textboxes to an Excel userform during runtime using vba. Now, the issue is I'm trying to retrieve data from those dynamically created textboxes. It's not that I can't get the data, it's that I can't pull it out of the form and use it once the form is closed. I used the following code sets for retrieving data from a single option textbox and it works perfectly: Private Sub SOSubmitButton_Click() FLNAmt =

How to insert a picture from the internet into VBA Excel Userform

痞子三分冷 提交于 2019-12-25 06:49:46
问题 I found some VB code here, but I need it for VBA. After reading this code I tried messing around with this code, but still trying to figure it out. Also, someone else had this problem before as shown here, but there was no explicit solution. The code I am working with: Sub Image1Insert() Application.ScreenUpdating = False Dim strPath As String strPath = "https://www.gravatar.com/avatar/fbd7dcb2d47ddcd7e6a799bde3ec0ef6?s=48&d=identicon&r=PG&f=1" UserForm1.Image1.Picture = LoadPicture(strPath)

VBA combobox additem and getting a runtime error 70

会有一股神秘感。 提交于 2019-12-25 03:33:06
问题 I have created a userform that has two buttons on it. One is called CmdCon6 and the other is called CmdLbs6. When clicked, they are suppose to close the current userform, pull up another userform, and pull values from the 4th column in sheet18 and add them to a combobox named x48 (both of the new userforms have a combobox named x48)in the new userform. The range of cell values to be added to the combobox x48 will flucuate, but never exceed 20 (hence why I added a loop). Everything works great