PC Review
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Event handling and conflicts in updating a CDO property
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Event handling and conflicts in updating a CDO property
![]() |
Event handling and conflicts in updating a CDO property |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
I'm using CDO to update the "Flag for Follow Up" properties in a custom
contact form in a public folder. After the update, I even close the item, dereference it, and reopen it to make sure that any subsequent changes made by the user don't cause conflicting edits. This works just fine if I invoke the macro from the VBA window, via Tools-->Macro, or hand build a toolbar button. However, if I use the code below to create a new button in a new toolbar, and click on the button to fire the macro, I get conflicting edits. The information store is getting updated (I can see the new values in the folder view), but the update is not displayed in the item view. If the user then makes a change to the item and saves it, it causes conflicting edits, one item with the original Due By date and other Follow Up Flag information and the user's edits, the other item with the updated flag information and no new edits. (A Save & Close without a subsequent edit doesn't cause a conflicting edit.) I suspect the problem has to do with the event handling. Is the menu bar code capturing a PropertyChange event, and somehow impacting the display of the item? If so, how do I resolve? If not, what else could be causing this behavior? Here's the toolbar code: Function CreateCRMfuToolbar() As Office.CommandBar Dim objApp As Outlook.Application Dim objCBs As Office.CommandBars Dim objCB As Office.CommandBar Dim objCBControls As Office.CommandBarControls Dim objControl As Office.CommandBarControl On Error Resume Next Set objApp = CreateObject("Outlook.Application") Set objCBs = objApp.ActiveInspector.CommandBars Set objCB = objCBs.Add("FollowUpBar", msoBarFloating) objCB.Visible = True Set objControl = objCBControls.Add(msoControlButton) With objControl .AddItem .Caption = "SetNextFUDate" .FaceId = 33 .OnAction = "setNextFUDate" .Style = msoButtonIconAndCaption .TooltipText = "Set Next Follow Up Date" .Visible = True End With Set objControl = Nothing Set objCBControls = Nothing Set objCB = Nothing Set objCBs = Nothing Set objApp = Nothing End Function Many thanks, DArhelger |
|
|
|
#2 |
|
Guest
Posts: n/a
|
What happens if you click on your code-builded button? Did you check if
your macro starts? > Dim objControl As Office.CommandBarControl For receiving the click events you need to declare the variable "WithEvents" in the head of your form and you need to declare it as CommandBarButton, because the -Control doesn´t fire any event. -- Viele Grüße Michael Bauer "darhelger" <darhelger@yahoo.com> wrote in message news:10olp4spqbj6faf@corp.supernews.com... > I'm using CDO to update the "Flag for Follow Up" properties in a custom > contact form in a public folder. > After the update, I even close the item, dereference it, and reopen it to > make sure that any subsequent > changes made by the user don't cause conflicting edits. This works just fine > if I invoke the macro from > the VBA window, via Tools-->Macro, or hand build a toolbar button. > > However, if I use the code below to create a new button in a new toolbar, > and click on the button to > fire the macro, I get conflicting edits. The information store is getting > updated (I can see the new values > in the folder view), but the update is not displayed in the item view. If > the user then makes a change to > the item and saves it, it causes conflicting edits, one item with the > original Due By date and other > Follow Up Flag information and the user's edits, the other item with the > updated flag information and > no new edits. (A Save & Close without a subsequent edit doesn't cause a > conflicting edit.) > > I suspect the problem has to do with the event handling. Is the menu bar > code capturing a > PropertyChange event, and somehow impacting the display of the item? If so, > how do I resolve? > If not, what else could be causing this behavior? > > Here's the toolbar code: > > Function CreateCRMfuToolbar() As Office.CommandBar > > Dim objApp As Outlook.Application > Dim objCBs As Office.CommandBars > Dim objCB As Office.CommandBar > Dim objCBControls As Office.CommandBarControls > Dim objControl As Office.CommandBarControl > On Error Resume Next > Set objApp = CreateObject("Outlook.Application") > Set objCBs = objApp.ActiveInspector.CommandBars > Set objCB = objCBs.Add("FollowUpBar", msoBarFloating) > > objCB.Visible = True > > Set objControl = objCBControls.Add(msoControlButton) > With objControl > .AddItem > .Caption = "SetNextFUDate" > .FaceId = 33 > .OnAction = "setNextFUDate" > .Style = msoButtonIconAndCaption > .TooltipText = "Set Next Follow Up Date" > .Visible = True > End With > > Set objControl = Nothing > Set objCBControls = Nothing > Set objCB = Nothing > Set objCBs = Nothing > Set objApp = Nothing > > End Function > > Many thanks, > > DArhelger > > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Yes, the macro starts and runs to completion. All the click event has to do
is run the macro, which it does. What I suspect is that adding the additional event handling layer of the custom button somehow mucking with the item refresh so the property change doesn't get displayed (although it is stored). DArhelger "Michael Bauer" <mib00@t-online.de> wrote in message news:uJc7XqwwEHA.3808@TK2MSFTNGP15.phx.gbl... > What happens if you click on your code-builded button? Did you check if > your macro starts? > >> Dim objControl As Office.CommandBarControl > > For receiving the click events you need to declare the variable > "WithEvents" in the head of your form and you need to declare it as > CommandBarButton, because the -Control doesn´t fire any event. > > -- > Viele Grüße > Michael Bauer > > > "darhelger" <darhelger@yahoo.com> wrote in message > news:10olp4spqbj6faf@corp.supernews.com... >> I'm using CDO to update the "Flag for Follow Up" properties in a > custom >> contact form in a public folder. >> After the update, I even close the item, dereference it, and reopen it > to >> make sure that any subsequent >> changes made by the user don't cause conflicting edits. This works > just fine >> if I invoke the macro from >> the VBA window, via Tools-->Macro, or hand build a toolbar button. >> >> However, if I use the code below to create a new button in a new > toolbar, >> and click on the button to >> fire the macro, I get conflicting edits. The information store is > getting >> updated (I can see the new values >> in the folder view), but the update is not displayed in the item view. > If >> the user then makes a change to >> the item and saves it, it causes conflicting edits, one item with the >> original Due By date and other >> Follow Up Flag information and the user's edits, the other item with > the >> updated flag information and >> no new edits. (A Save & Close without a subsequent edit doesn't cause > a >> conflicting edit.) >> >> I suspect the problem has to do with the event handling. Is the menu > bar >> code capturing a >> PropertyChange event, and somehow impacting the display of the item? > If so, >> how do I resolve? >> If not, what else could be causing this behavior? >> >> Here's the toolbar code: >> >> Function CreateCRMfuToolbar() As Office.CommandBar >> >> Dim objApp As Outlook.Application >> Dim objCBs As Office.CommandBars >> Dim objCB As Office.CommandBar >> Dim objCBControls As Office.CommandBarControls >> Dim objControl As Office.CommandBarControl >> On Error Resume Next >> Set objApp = CreateObject("Outlook.Application") >> Set objCBs = objApp.ActiveInspector.CommandBars >> Set objCB = objCBs.Add("FollowUpBar", msoBarFloating) >> >> objCB.Visible = True >> >> Set objControl = objCBControls.Add(msoControlButton) >> With objControl >> .AddItem >> .Caption = "SetNextFUDate" >> .FaceId = 33 >> .OnAction = "setNextFUDate" >> .Style = msoButtonIconAndCaption >> .TooltipText = "Set Next Follow Up Date" >> .Visible = True >> End With >> >> Set objControl = Nothing >> Set objCBControls = Nothing >> Set objCB = Nothing >> Set objCBs = Nothing >> Set objApp = Nothing >> >> End Function >> >> Many thanks, >> >> DArhelger >> >> > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Sorry, my fault, I can´t help you.
I have read your posting yesterday a few times, this morning again but I don´t understand the context. :-( -- Viele Grüße Michael Bauer "darhelger" <darhelger@yahoo.com> wrote in message news:10omdb2ots3oe78@corp.supernews.com... > Yes, the macro starts and runs to completion. All the click event has to do > is run the macro, which it does. > > What I suspect is that adding the additional event handling layer of the > custom button somehow mucking with the item refresh so the property change > doesn't get displayed (although it is stored). > > DArhelger > > "Michael Bauer" <mib00@t-online.de> wrote in message > news:uJc7XqwwEHA.3808@TK2MSFTNGP15.phx.gbl... > > What happens if you click on your code-builded button? Did you check if > > your macro starts? > > > >> Dim objControl As Office.CommandBarControl > > > > For receiving the click events you need to declare the variable > > "WithEvents" in the head of your form and you need to declare it as > > CommandBarButton, because the -Control doesn´t fire any event. > > > > -- > > Viele Grüße > > Michael Bauer > > > > > > "darhelger" <darhelger@yahoo.com> wrote in message > > news:10olp4spqbj6faf@corp.supernews.com... > >> I'm using CDO to update the "Flag for Follow Up" properties in a > > custom > >> contact form in a public folder. > >> After the update, I even close the item, dereference it, and reopen it > > to > >> make sure that any subsequent > >> changes made by the user don't cause conflicting edits. This works > > just fine > >> if I invoke the macro from > >> the VBA window, via Tools-->Macro, or hand build a toolbar button. > >> > >> However, if I use the code below to create a new button in a new > > toolbar, > >> and click on the button to > >> fire the macro, I get conflicting edits. The information store is > > getting > >> updated (I can see the new values > >> in the folder view), but the update is not displayed in the item view. > > If > >> the user then makes a change to > >> the item and saves it, it causes conflicting edits, one item with the > >> original Due By date and other > >> Follow Up Flag information and the user's edits, the other item with > > the > >> updated flag information and > >> no new edits. (A Save & Close without a subsequent edit doesn't cause > > a > >> conflicting edit.) > >> > >> I suspect the problem has to do with the event handling. Is the menu > > bar > >> code capturing a > >> PropertyChange event, and somehow impacting the display of the item? > > If so, > >> how do I resolve? > >> If not, what else could be causing this behavior? > >> > >> Here's the toolbar code: > >> > >> Function CreateCRMfuToolbar() As Office.CommandBar > >> > >> Dim objApp As Outlook.Application > >> Dim objCBs As Office.CommandBars > >> Dim objCB As Office.CommandBar > >> Dim objCBControls As Office.CommandBarControls > >> Dim objControl As Office.CommandBarControl > >> On Error Resume Next > >> Set objApp = CreateObject("Outlook.Application") > >> Set objCBs = objApp.ActiveInspector.CommandBars > >> Set objCB = objCBs.Add("FollowUpBar", msoBarFloating) > >> > >> objCB.Visible = True > >> > >> Set objControl = objCBControls.Add(msoControlButton) > >> With objControl > >> .AddItem > >> .Caption = "SetNextFUDate" > >> .FaceId = 33 > >> .OnAction = "setNextFUDate" > >> .Style = msoButtonIconAndCaption > >> .TooltipText = "Set Next Follow Up Date" > >> .Visible = True > >> End With > >> > >> Set objControl = Nothing > >> Set objCBControls = Nothing > >> Set objCB = Nothing > >> Set objCBs = Nothing > >> Set objApp = Nothing > >> > >> End Function > >> > >> Many thanks, > >> > >> DArhelger > >> > >> > > > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

