userform

Why does Showing a UserForm as Modal Stop Code Execution?

谁都会走 提交于 2019-11-30 14:00:16
The following VBA code stops at Me.Show . From my tests, it seems that Me.Show stops all code execution, even if the code is inside the UserForm. This part is outside the UserForm : Public Sub TestProgress() Dim objProgress As New UserForm1 objProgress.ShowProgress Unload objProgress End Sub This part is inside the UserForm : Private Sub ShowProgress() Me.Show vbModal Dim intSecond As Integer For intSecond = 1 To 5 Application.Wait Now + TimeValue("0:00:01") Me.ProgressBar1.Value = intSecond / 5 * 100 Next intSecond Me.Hide End Sub The code stops at Me.Show , after the UserForm is displayed.

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

廉价感情. 提交于 2019-11-30 09:07:21
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 slow interpreted language like VBA When code execution is interrupted (pressing the stop button, or

Pass data between UserForms

旧时模样 提交于 2019-11-30 04:04:07
Within Excel VBA I have a User Form similar to the following where the user enters an ID number and then the details are displayed on the user form: Private Sub btnIDNo_Click() Dim IDNo As Long If txtIDNo.Text <> "" Then If IsNumeric(txtIDNo.Text) = True Then lblError.Caption = "" IDNo = txtIDNo.Text Worksheets("Details").Activate Range("B4").Select While ActiveCell.Value <> "" And ActiveCell.Value <> IDNo ActiveCell.Offset(1, 0).Select Wend If ActiveCell.Value = IDNo Then txtName.Value = ActiveCell.Offset(0, 1).Value txtPhone.Value = ActiveCell.Offset(0, 2).Value Else lblError.Caption =

Remove Dynamically Added Controls from Userform

帅比萌擦擦* 提交于 2019-11-30 03:20:26
问题 I have an excel Userform with dynamically added checkboxes. I add the checkboxes early on with code that looks like this: Set chkBox = Me.Controls.Add("Forms.Checkbox.1", "Checkbox" & i) Later, I want to remove all of these checkboxes. I'm trying this code: Dim j As Integer 'Remove all dynamically updated checkboxes For Each cont In Me.Controls For j = 1 To NumControls If cont.Name = "Checkbox" & j Then Me.Controls.Remove ("Checkbox" & j) End If Next j Next cont But am getting the following

Not enough memory crash when loading VBA userform

早过忘川 提交于 2019-11-29 23:33:01
问题 Background: I have a VBA userform with ~1050 checkboxes, and ~100 labels, all populated from the active Sheet. The labels are taken directly from the sheet, based on the ActiveCell.Row (t and i are the rows of specific information in relation to the ActiveCell, where there are 20 different tables on the same sheet where the userform would be pulled from when double-clicked). The event to load the userform ("Stb") is a doubleclick event which doesn't appear to cause the issue. Issue: Seemingly

How to detect a mouse_down on a Userform Frame while the mouse is still down

雨燕双飞 提交于 2019-11-29 18:02:12
I want to detect when there's a mouse_down on any Frame on the Form while the mouse is still down. I know how to do it for a Click, but I want to catch it before mouse_up. Thanks You can create a _MouseDown event handler for each frame on the form, or if you have many frames you can create a generic event handler class Create a Class module (eg named cUserFormEvents ) Public WithEvents Frme As MSForms.frame Public frm As UserForm Private Sub Frme_MouseDown( _ ByVal Button As Integer, _ ByVal Shift As Integer, _ ByVal X As Single, _ ByVal Y As Single) ' Put your event code here MsgBox Frme

adding multiple labels and textboxes to an Excel userform during runtime using vba

自闭症网瘾萝莉.ら 提交于 2019-11-29 16:28:42
问题 I'm creating an inventory management tool with Excel VBA. I've created code that gathers a list of names from a drop down box on Internet Explorer and puts them into an array. What I need to do is something similar to vba create several textboxes comboboxes dynamically in userform, but I would be dynamically adding labels for the user names and textboxes for the number of FLNs each person would be receiving. These would then go into a predefined userform I've already created. Per the code

Why does Showing a UserForm as Modal Stop Code Execution?

我们两清 提交于 2019-11-29 14:24:57
问题 The following VBA code stops at Me.Show . From my tests, it seems that Me.Show stops all code execution, even if the code is inside the UserForm. This part is outside the UserForm : Public Sub TestProgress() Dim objProgress As New UserForm1 objProgress.ShowProgress Unload objProgress End Sub This part is inside the UserForm : Private Sub ShowProgress() Me.Show vbModal Dim intSecond As Integer For intSecond = 1 To 5 Application.Wait Now + TimeValue("0:00:01") Me.ProgressBar1.Value = intSecond

How To Display Part of Excel on VBA Form

一世执手 提交于 2019-11-29 10:20:55
I have a file on .csv format and from A-S columns, it has some records like a table. My complete program will insert/remove/delete/add some rows, columns and editing cell values etc. I managed to code all the operations that i need, now i'm trying to integrate it with a gui. What I want is to display cells from Ax1 to the last column that has record on VBA user form. How can i do that? *ps: again, my file's format is .csv and I am using Excel 2007 You can use a multi column Listbox to show the data. LOGIC Import the text (Csv) file in the temp sheet Show that data in the multicolumn Listbox

Is it better to show ProgressBar UserForms in VBA as modal or modeless?

主宰稳场 提交于 2019-11-29 10:14:39
Is it better to show ProgressBar UserForms in VBA as modal or modeless? What are the best practices for developing progress indicators in VBA? Modeless UserForms require the use of Application.Interactive = False , whereas Modal UserForms by their very nature block any interaction with the application until the core procedure has finished, or is cancelled. If Application.Interactive = False is used, however, the Esc key interrupts code execution, so the use of Application.EnableCancelKey = xlErrorHandler and error handling ( Err.Number = 18 ) is required in both the UserForm and the calling