Marco doesn't show up when using Alt-F8

Status
Not open for further replies.

Michiel

New Member
Outlook version
Outlook 2013 64 bit
Email Account
IMAP
I found a nice script on slipstick website by Diane. Unfortunately I cannot get them to run. I am a bit new at VBA. I want to use the script Reply to a web form generated message. I already have some macros that work. In ThisOutlookSession I have pasted the code above below the other macros. The name SendNew shows up in the right corner where the name of the macros are displayed. But when I save, it doesn't show up when I hit Alt-F8. When I remove Item As Outlook.MailItem from between the brackets, the name SendItem does show up when I hit Alt-F8, but there is an error 424 in the script now. So a bit of a catch 22. I would love some advice on how to solve this. I have googled quite a bit...
This same issue, that a name of a script that I download from the internet shows up in the right top corner, but when I save, it doesn't show up when I hit Alt-F8, happens frequently, so there is something basic there that I don't understand.
The script from Diane:

Sub SendNew(Item As Outlook.MailItem)
Dim Reg1 As Object
Dim M1 As Object
Dim M As Object
Dim strAddress As String

Set Reg1 = CreateObject("VBScript.RegExp")

With Reg1
.Pattern = "(([\w-\.]*\@[\w-\.]*)\s*)"
.IgnoreCase = True
.Global = False
End With

If Reg1.Test(Item.Body) Then

Set M1 = Reg1.Execute(Item.Body)
For Each M In M1
strAddress = M.SubMatches(1)
Next
End If

Dim objMsg As MailItem
Set objMsg = Application.CreateItemFromTemplate("C:\path\to\template.oft")

objMsg.Recipients.Add strAddress

' Copy the original message subject
objMsg.Subject = "Thanks: " & Item.Subject

' use for testing
objMsg.display

' objMsg.Send

End Sub

 
This part: Sub SendNew(Item As Outlook.MailItem) means it needs to be called by another macro (or a run a script rule). If you remove the mailitem part, you need to set the item in the macro.

This should work to call the macro for the selected item. If you want it to work with open or selected items, get the function from Outlook VBA: Work with Open Item or Selected Item and use
Set Item = GetCurrentItem()

if you want to use 1 macro, you need to add the dim and set to the original macro (and remove the item as mailitem part)

Code:
sub runmacro()
Dim Item As Outlook.MailItem

Set Item = Application.ActiveExplorer.Selection.Item(1)

SendNew Item
end sub
 
Hi Diane,
The first part of your explanation I didn't quite follow, but the last part worked for me. :) I pasted your code below the original code, deleted the text between the brackets and works like a charm. Thank you!
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
J Marco in search of text in subject line Using Outlook 8
G Outlook 365 My iCloud Outlook doesn’t work after reinstalling Microsoft365 on Windows 10 PC – now I get error message on contacts and calendar Using Outlook 1
E Save Selected Email Message as .msg File - digitally sign email doesn't works Outlook VBA and Custom Forms 1
M Shift Delete doesn't delete email from server Using Outlook 3
C Outlook doesn't feel reliable, anymore Using Outlook 5
C View doesn't refresh (fields or formatting) Using Outlook 1
J search doesn't find anything Using Outlook 1
gproston Why doesn't Outlook remember indexing? Using Outlook 1
R Why doesn't outlook use "Normal" style for new messages? Using Outlook 4
J outlook 2007 doesn't let me choose which .pst to search Using Outlook 2
R Follow up button doesn't working neither the reminders in BCM BCM (Business Contact Manager) 0
Terry Sullivan Sender's Name Doesn't Appear in the From Field on Outlook 365/IMAP Using Outlook 2
B VBScript doesn't run on Recipient Email Outlook VBA and Custom Forms 2
P Outlook Mobile App Doesn't Refresh Inbox Using Outlook 0
DoctorJellybean Outlook 365 doesn't always mark emails as read Using Outlook 3
GregS Simple calendar sharing doesn't work Using Outlook 6
G Calendar View in Outlook Office 365 - Doesn't show enough hours, and the 30/60 min choice isn't the solution Using Outlook 4
P Desktop doesn't index Outlook IMAP files, laptop Outlook does index those same IMAP files Using Outlook 2
B Outlook rule run a Script doesn't work Outlook VBA and Custom Forms 1
E Accessing shared outlook folder doesn't work since switch to new outlook/excel Outlook VBA and Custom Forms 11
H VB script in outlook form doesn't work anymore Outlook VBA and Custom Forms 2
J Junk mail doesn't work Using Outlook 3
J Custom form code doesn't run Outlook VBA and Custom Forms 2
Laurent Duchastel New email setup dialog doesn't allow alias Using Outlook 2
M Item edits doesn't always sync Using Outlook 11
C scanpst.exe doesn't repair .pst file Using Outlook 1
Caio "From" field doesn't show extra email addresses in Outlook 2016. Using Outlook.com accounts in Outlook 6
O Worksheet doesn't show on jumplist Using Outlook 1
C Outlook 2016 doesn't show contacts in address book Using Outlook 2
Vijay Run script doesn't work in outlook Using Outlook 1
Diane Poremsky Category Color doesn't Display in Inbox Using Outlook 0
S Outlook 2013 doesn't download html messages Using Outlook 0
L Run a Script Rule doesn't work Using Outlook 5
M Google Apps Mail *SENT* from iPhone doesn't download to Outlook via POP3 Using Outlook 1
P AutoForward Randomly Doesn't fwd emails Using Outlook 3
Diane Poremsky Receive a Reminder When a Message Doesn't Arrive? Using Outlook 10
K Macro doesn't recognize local mails from colleagues Outlook VBA and Custom Forms 2
W Filter condition "contains"/"doesn't contain" doesn't always work Using Outlook 10
M Outlook hidden even when open (maximising doesn't fix it) Using Outlook 2
Z outlook 2007 - opening a contact from the search results doesn't use the custom form Using Outlook 10
M Address book doesn't update contacts? Please any help would be great! Exchange Server Administration 4
A yahoo mail doesn't send or receive reliably Using Outlook 1
S VBA to modify appointment item in additional Exchange account doesn't work Using Outlook 0
G Outlook2013 - "From" name doesn't change even when changed in Account Setting Using Outlook 4
T doesn't show up previous info (email, contacts and tasks)after windows up date Using Outlook 0
O Change folder doesn't work Using Outlook 2
G run-time 438: object doesn't support this property or method Using Outlook 2
S MAC outlook doesn't show the meeting organizer detail Using Outlook 0
S Newly added user doesn't show up in GAL but available in OWA, Using Outlook 0
B Archiving of emails doesn't work anymore Using Outlook 3

Similar threads

Back
Top