A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Cannot find Accounts Control ID:=31224



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 7th 06, 11:40 PM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 23
Default Cannot find Accounts Control ID:=31224

I am using code copied at end of this message to try and change the
"send
from" account. Code is based on Sue Mosher's Book example. For some
reason
the Send From address does not change. The problem appears to be that
the Send From Account does not get changed even throug the line is run.
I have tried this code on Outlook 2000/ 2002


Any help will be greatly appreciated.
Thanks in advance
Neil


Option Explicit
Const ACCT_TO_USE = "Someaccount"


Private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)
'How can we get the name of the account that will be used to send


Dim objInsp As Outlook.Inspector
Dim colCB As Office.CommandBars
Dim objCBAccounts As Office.CommandBarPopup
Dim objCBB As Office.CommandBarButton
Dim blnAccountFound As Boolean


Set objInsp = Item.GetInspector
Set colCB = objInsp.CommandBars
Set objCBAccounts = colCB.FindControl(ID:=31224)
Set objCBB = objCBAccounts.Controls.Item(1)


If Not objCBB Is Nothing Then
If objCBB.Caption ACCT_TO_USE Then
Set objCBB = Nothing
For Each objCBB In objCBAccounts.Controls
If InStr(1, objCBB.Caption, ACCT_TO_USE, vbTextCompare)
0

Then
blnAccountFound = True
Err.Clear
objCBB.Execute


Exit For
End If
Next
End If


If blnAccountFound = False Or Err.Number 0 Then
Cancel = True
End If
End If


Set objInsp = Nothing
Set colCB = Nothing
Set objCBAccounts = Nothing
Set objCBB = Nothing


End Sub

  #2  
Old May 16th 06, 04:29 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Cannot find Accounts Control ID:=31224

That technique won't work if Word is the email editor. See
http://www.outlookcode.com/codedetail.aspx?id=889 for various other approaches .

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

wrote in message oups.com...
I am using code copied at end of this message to try and change the
"send
from" account. Code is based on Sue Mosher's Book example. For some
reason
the Send From address does not change. The problem appears to be that
the Send From Account does not get changed even throug the line is run.
I have tried this code on Outlook 2000/ 2002


Any help will be greatly appreciated.
Thanks in advance
Neil


Option Explicit
Const ACCT_TO_USE = "Someaccount"


Private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)
'How can we get the name of the account that will be used to send


Dim objInsp As Outlook.Inspector
Dim colCB As Office.CommandBars
Dim objCBAccounts As Office.CommandBarPopup
Dim objCBB As Office.CommandBarButton
Dim blnAccountFound As Boolean


Set objInsp = Item.GetInspector
Set colCB = objInsp.CommandBars
Set objCBAccounts = colCB.FindControl(ID:=31224)
Set objCBB = objCBAccounts.Controls.Item(1)


If Not objCBB Is Nothing Then
If objCBB.Caption ACCT_TO_USE Then
Set objCBB = Nothing
For Each objCBB In objCBAccounts.Controls
If InStr(1, objCBB.Caption, ACCT_TO_USE, vbTextCompare)
0

Then
blnAccountFound = True
Err.Clear
objCBB.Execute


Exit For
End If
Next
End If


If blnAccountFound = False Or Err.Number 0 Then
Cancel = True
End If
End If


Set objInsp = Nothing
Set colCB = Nothing
Set objCBAccounts = Nothing
Set objCBB = Nothing


End Sub

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Control-click Required Jeni Q Outlook - General Queries 2 March 29th 06 03:48 PM
Using Tab Control in Addin Sanjay Singh Add-ins for Outlook 2 March 9th 06 04:19 AM
Radio Control Buttons BuddyLats Outlook and VBA 1 February 17th 06 06:30 PM
2003 calendar's find, doesn't find items created today till tomarr Support7556 Outlook - Calandaring 11 January 20th 06 10:54 PM
How to Program a Calendar Control Chaplain Doug Outlook - Using Forms 1 January 12th 06 03:53 PM


All times are GMT +1. The time now is 08:45 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.