Click here to Skip to main content
14,869,378 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Here i written code for create custom tab in my outlook 2007.But its raising error like object is required.please help me to a solution.My code is given below.

Sub AddCustomUI()
    Dim customUiXml As String

    customUiXml = "<mso:customUI xmlns:mso="""">" _
        & "<mso:ribbon><mso:tabs><mso:tab id=""myTab"" label=""New Tab"" " _
        & "insertBeforeQ=""mso:TabView"">" _
        & "<mso:group id=""group1"" label=""New Group"">" _
        & "<mso:button id=""button1"" label=""Test Button"" size=""large"" " _
        & "imageMso=""GetExternalDataFromText"" />" _
        & "</mso:group></mso:tab></mso:tabs></mso:ribbon></mso:customUI>"

    ActiveProject.SetCustomUI (customUiXml)//getting errorhere like object is required.
    End Sub

and tell me if there is another way to create custom tab in outlook 2007 with vba application.
Updated 2-Jun-17 11:00am
Richard MacCutchan 1-Oct-15 4:41am
What error, where does it occur?
Member 11944583 7-Oct-15 2:54am
object is required is the error message.I have mentioned in my code part also.see it please.
Richard MacCutchan 7-Oct-15 6:46am
Then add the required object to your code.

And please post the exact and complete text of the error message. Copying and pasting such information will help you get an answer much more quickly.
Maciej Los 1-Oct-15 4:49am
Do not post the same question again and again!
Member 11944583 7-Oct-15 2:56am
but i didnt get any perfect answer for any of my question thats why i have posted it again and again.

You can't add custom controls on MS Outlook ribbon via VBA! See my past answer[^].

You have to write COM Addin. Please refer this: Extending the User Interface in Outlook 2010[^]
Actually, you CAN add a custom control using VBA by editing the officeUI customization file as Outlook is started up.

Here is a sample solution...

experts-exchange solution: HOW-TO-Manipulating-Office-Ribbon-Bar-only-with-VBA

It is not perfect, as some error checking or checking to see if the custom tab, group and / or button already exists before trying to add it in again. Also, it seems that the code presented here doesn't quite handle the situation where there have been no customizations to the ribbon already made... at least in Outlook 2010.

Also, using similar methods of editing the same file, you can add custom buttons to the QAT (Quick Access Toolbar).

CHill60 2-Jun-17 18:01pm
I think the repeated references to "You have to close and reopen your office application to see it." is enough to push me towards doing it properly with an Add-In
Pat O'Brien 5-Jun-17 7:02am
Then I guess that you didn't read the whole post. You DO NOT have to close and reopen the office application to see it. In fact, it can be done outside of the application.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900