PDA

Click to See Complete Forum and Search --> : exporting email addresses from Outlook to Excel


itsonlyme4
Apr 27th, 2006, 08:22 AM
Not sure if this is the correct Forum for this question.. but here goes...

I have an existing Macro in Outlook that basically scans an entire Mailbox for Messages within a given data Range, dumps the data (date, email address and email message body) into an excel file and then converts the excel to .htm and places the .htm file output on a Network drive.

I would like to create a whole new Macro which will do ALMOST the same thing - utilizing part of the code from the first macro - I want to read all emails and put the email addresses ONLY into a excel file - excluding duplicates of course.

My problem is, When in Outlook, I do ALT/F11 to open the VB Editor and it pulls the code in from the first Macro.

I guess what I don't understand is - How to I create a new Macro from scratch ????

I tried going into Outlook/Tools/Macros and typing a new name and then clicking create - but it does the same thing !! it shows me the code from the first Macro!?

DO I need to create a new module or a whole new project??? Any guidance or help would be much appreciated.

signed,
a VBA Newbie

New2vba
Apr 27th, 2006, 08:35 AM
If you enter the code window for your existing macro, you will have:

Sub NameOfYourMacro()

'Code here...

End Sub

Where NameofYourMacro is exactly that.

It is the sub and end sub that define the start and end of you macro so to create a new one in the same module, go beneath the end of your existing code and type

Sub NewMacroName()

'Enter code here...

End Sub

Where NewMacroName is the name you want to give your Macro.

I am a novice myself so there is probably a better explanation than this, but I think it should get you started.

BTW when you try to create a macro through Outlook - Tools - Macro and you press create, you are taken to the VBE to add your code to the new Macro (You should see the above Sub / End sub, but using the name you defined.

itsonlyme4
Apr 27th, 2006, 09:42 AM
OK.. so basically to create a whole new Macro I'm appending to the original code? If I start at the bottom of the existing code and use
Sub NameOfYourMacro()
'Code here...
End Sub

I will get a new Macro in my Tools/Macro pulldown list in Outlook????

New2vba
Apr 27th, 2006, 11:55 AM
Yes, but you are not appending to the original code - you are simply inserting it into the same module.

"Sub" indicates the beginnning of your routine and "End Sub" indicates the end, so you will have 2 separate routines.

This could probably be explained to you in more detail, but my username is quite literal - as I have already said, I am a novice myself. :blush:

Hope this helps.