Hello Everybody,
Is there a way to record a macro in outlook (lets say 2003)?
like you can do i excel...
Thank you all in advance,
ERAN
Printable View
Hello Everybody,
Is there a way to record a macro in outlook (lets say 2003)?
like you can do i excel...
Thank you all in advance,
ERAN
No, you can not record a macro in Outlook.Quote:
Originally Posted by eranfox
You can write macros in Outlook by going to the Tools menu, point to Macro, and then click Macros.
In the Macro name box, type a name for your macro, and then click Create. The Microsoft Visual Basic Editor opens.
Type or paste your code into the code window of the module.
But, as I said, you cannot record a macro in Outlook.
Hello Hack,Quote:
Originally Posted by Hack
I know how to write macros in outlook - well i started to do that only today...
but i was looking for the record new macro line and didnt find it - you just answered my question.
I wonder why you cant record a macro in outlook like you do in excel...
Thank you for your reply,
ERAN
For reasons known only to Microsoft, the VBA capabilities of Outlook (all versions) has been well below the VBA capabilities of all of the other Office products.Quote:
Originally Posted by eranfox
It does make you just sit back and shake your head!
Ooooh nooo, tell me you didnt diss on Outlook! :D
Outlook can be considered to have more advanced VBA support then all other Office suite app with only Excel as a close competitor. Maybe Outlook doesnt allow you to record a macro because of security reasons and spam, virus', etc. The Forms support alone is far far better then any Office VBA Forms capabilities combined. I could go on and on but anyways... :D
Is there something in particular you need to do that you needed to record a macro?
Hello RobDog888,Quote:
Originally Posted by RobDog888
Nothing special...just wanted to know if i can programmaticaly create a button .
i know how to do it semi automatic:
1)create the code for the button
2)Choose View | Toolbars | Customize.
In the Customize dialog, go to the Commands tab.
Under Categories, select Macros.
Drag the Project1.myMacro macro command to the desired toolbar.
Right-click on the new Project1.myMacro toolbar button, then change the Name or button appearance as desired.
Close the Customize dialog.
is there a way to do number 2 programmaticaly?
Thank you in advance,
ERAN
Yup. Do you want a toolbar button or menu item?
Well if thats the case...Quote:
Originally Posted by RobDog888
i want to be greedy,can you show me the two possibilities?
Thank you RobDog888 in advance,
ERAN
Sorry for the delay but I have been too busy multi-tasking. I will work up a toolbar example too.
VB Code:
Option Explicit 'Behind ThisOutlookSession Public WithEvents oMnuSaveAs As Office.CommandBarButton Private Sub SyncMnuSaveAsButton(btn As Office.CommandBarButton) Set oMnuSaveAs = btn If btn Is Nothing Then MsgBox "Sync. of '" & btn.Caption & "' button event failed!", vbCritical + vbOKOnly End If End Sub Private Sub Application_MAPILogonComplete() Dim oCBmnuTools As Office.CommandBarPopup Dim oCBmnuSaveMe As Office.CommandBarButton '<ADD A MENU ITEM> Set oCBmnuTools = Application.ActiveExplorer.CommandBars("Menu Bar").Controls("&Tools") Set oCBmnuSaveMe = Application.ActiveExplorer.CommandBars("Menu Bar").FindControl(msoControlButton, 1, "888", True, True) If TypeName(oCBmnuSaveMe) = "Nothing" Then Set oCBmnuSaveMe = oCBmnuTools.Controls.Add(msoControlButton, 1, "888", , True) End If With oCBmnuSaveMe .BeginGroup = True .Caption = "Save Email As..." .Enabled = True .Style = msoControlCustom .Tag = "888" .Visible = True End With Call SyncMnuSaveAsButton(oCBmnuSaveMe) '</ADD A MENU ITEM> End Sub Private Sub oMnuSaveAs_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean) MsgBox "oMnuSaveAs_Click" End Sub
Hello RobDog888 thank you for your reply!!!
I just want to know where exactly to place this code and how to save it.
do i save it as a dll or somthing like that.
i new to this outlook programming so sorry for asking maybe stupid questions...
Thanx again,
ERAN
Ok, no prob. For this example you need to open Outlook and press Alt + F11 to open the VBA IDE. Then inside "ThisOutlookSession" you can paste all the code. Save the class and close Outlook. Re-open it and click the tools menu > Save Email As... and you will get your event to fire. In this example its a msgbox.
Hello RobDog888,
There is somthing i still dont understand:
where is the tools menu with the option of save email as?
i did everything you said,but i cant find this tools menu...what is wrong?
Thank you again,
ERAN
Did you close and log off of Outlook and then restart it enabling macros?
Hello RobDog888,
Well, in my tools menu i have everything except speech and save email as ...
I went to View->ToolBars and searched for these two but nothing...
What is wrong with my outlook version (2003(11.5608.5606))?
Thank you in advance,
ERAN
Did you paste the code into "ThisOutlookSession" class, enable macros, and restart Outlook?
Also, it looks like you dont have Service Pack 1 for Outlook/Office installed. You may want to eventually do an Office Update.
Edit: Make sure you have the reference to MS Office 11.0 Object Library. And you did say your running 2003?
Hello ,
Silly me, I forgot to enable Macros ,But still have difficulties...
I get Run time Error on this Line:
Run time Error 5VB Code:
Set oCBmnuTools = Application.ActiveExplorer.CommandBars("Menu Bar").Controls("&Tools")
Invalid procedure call or argument
Any Ideas?
ERAN
Just take the command bars part and try to print out the captions for your controls.
See if the Tools control is spelled the same and present.VB Code:
Dim i As Integer For i = 1 to Application.ActiveExplorer.CommandBars("Menu Bar").Controls.Count Debug.Print Application.ActiveExplorer.CommandBars("Menu Bar").Controls(1).Name Next
Hello RobDog888,Quote:
Originally Posted by RobDog888
OK It's working!!!
two things:
1)I forgot to tell you i'm using the hebrew version - that is why &tools is not recognized because the name is in hebrew.
2)Debug.Print Application.ActiveExplorer.CommandBars("Menu Bar").Controls(1).Caption ->i got an error when tried to use Name
Thank you so much for your help!!!
Now i'll go and find how to do this from vb ->write a DLL That will be loaded when outlook launches.
Best Regards,
ERAN :thumb: :wave:
p.s.
I gave it a resolved title but if you can please send me the other code we talked about ( toolbar example )...