none
I have not been able to figure out why code does NOT run UNTIL i close userFrom with cboAfterUpdateEvent. RRS feed

  • Question

  • I do not know what is important or not for this issue so I entered code all that

    seem to be related. The "mcrVenTorHardCopy" is mostly the same for all picks of

    cboVendor. Only differences are a few settings like PageHeight and PageWIdth.

    Private Sub UserForm_Initialize() Dim arr(0 To 12) As String arr(0) = "TOR Hard Cover" arr(1) = "TOR Trade" arr(2) = "TOR Mass Market" arr(3) = "Regular Formating" Me.cboVendors.List = arr With Me.cboVendors .ColumnHeads = True End With End Sub

    Private Sub cboVendors_AfterUpdate() Dim varResult As Variant varResult = Me.cboVendors.Value Select Case varResult Case "TOR Hard Cover" Call mcrVenTorHardCopy Case "TOR Mass Market" Call mcrVenTorMassMarket MsgBox "TOR Mass Market" Case "Regular Formating" Call mcrPageLayOut End Select MsgBox varResult 'SEEMS all MSGBOXes RUN AFTER userForm IS CLOSED. End Sub Public Sub mcrVenTorHardCopy() ' ' mcrVenTorHardCopy Macro ' ' This is Sample of possible changes to Page Layout. Used as template for other Vendors. ' Selection.WholeStory With ActiveDocument.Styles(wdStyleNormal).Font If .NameFarEast = .NameAscii Then .NameAscii = "" End If .NameFarEast = "" End With With ActiveDocument.PageSetup .LineNumbering.Active = True '<< Line #'s .Orientation = wdOrientPortrait .PageWidth = InchesToPoints(8.5) .PageHeight = InchesToPoints(11) '<< 11 Height .FirstPageTray = wdPrinterDefaultBin .OtherPagesTray = wdPrinterDefaultBin .SectionStart = wdSectionNewPage .OddAndEvenPagesHeaderFooter = False .DifferentFirstPageHeaderFooter = False .VerticalAlignment = wdAlignVerticalTop .SuppressEndnotes = False .MirrorMargins = False End With End Sub


    I have a UserForm with a comboBox with AfterUpdate Event. in that procedure, I have code run. BUT only runs after I close the userform. Then Rest of the code in the AfterEvent procedure works.


    Mark J

    Saturday, July 21, 2018 10:13 AM

Answers

  • Hello Mark,

    AfterUpdate will occur once you finish editing the combo box. And if you just select the item, Word will not know if you has finished editing since you are still focus on the control. If you select an item and then click on another control, such as a textbox, you will find the AfterUpdate event triggered.

    If you do want to trigger the an event while selecting the item, please try Change event.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by PuzzledByWord Wednesday, July 25, 2018 12:49 AM
    Monday, July 23, 2018 1:57 AM

All replies

  • Hello Mark,

    AfterUpdate will occur once you finish editing the combo box. And if you just select the item, Word will not know if you has finished editing since you are still focus on the control. If you select an item and then click on another control, such as a textbox, you will find the AfterUpdate event triggered.

    If you do want to trigger the an event while selecting the item, please try Change event.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by PuzzledByWord Wednesday, July 25, 2018 12:49 AM
    Monday, July 23, 2018 1:57 AM
  • Terry,

    Thanks.

    I was thinking that the other code would run after I selected the item in the After_UpDate Event.  And I was thinking to use the Change Event I would have to have something selected first.

    Thanks again for explaining this strange, to me, happening.

    Mark


    Mark J

    Wednesday, July 25, 2018 12:57 AM