Outlook VB Code

Status
Not open for further replies.

ashleyyoung

Member
Outlook version
Email Account
Exchange Server
Hi There

I hope someone can help with this? I would like the following Macro that was recorded in Word 07 to work in Outlook 07...

Sub QA()

'

' QA Macro

'

'
Selection.TypeParagraph
Selection.TypeText Text:="We have made the following booking for you:"
Selection.TypeParagraph
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=3, NumColumns:= _
2, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed
With Selection.Tables(1)
If .Style <> "Table Grid" Then
.Style = "Table Grid"
End If
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
.ApplyStyleRowBands = True
.ApplyStyleColumnBands = False
End With
Selection.TypeText Text:="Date:"
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.TypeText Text:="Time:"
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.TypeText Text:="Location:"
Selection.MoveDown Unit:=wdLine, Count:=2
Selection.TypeParagraph
Selection.TypeBackspace
Selection.TypeText Text:= _
"PLEASE NOTE: If the above date/time is not what you have req"
Selection.TypeText Text:= _
"uested this is because the requested date/time has been take"
Selection.TypeText Text:= _
"n and the above details are for the next available slot."
Selection.TypeParagraph
Selection.TypeText Text:= _
"Cancellations can only be made up to 24 hours before the boo"
Selection.TypeText Text:= _
"ked slot. Please contact us either by emailing 'CC Business "
Selection.TypeText Text:= _
"Support' or by telephoning 8708 as soon as possible. For can"
Selection.TypeText Text:= _
"cellations outside of this 24 hour cut off, please contact '"
Selection.TypeText Text:= _
"CC Business Support' and the chair of that QA Panel."
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeBackspace
Selection.TypeText Text:="Thank you"
Selection.TypeParagraph
Selection.TypeText Text:="Business Support Team"

End Sub

Can anyone help as at the moment it's not working and I think I'm missing something really obvious.

Thank you :)
 
You need to reference the word object model in the VB Editor.

These should all be checked:

  • Visual Basic For Applications
  • Microsoft Outlook 12.0 Object Library
  • OLE Automation
  • Microsoft Office 12.0 Object Library
  • Microsoft Word 12.0 Object Library
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
Dr. Demento Analogous Outlook code to read info into an array (or collection or whatever) Outlook VBA and Custom Forms 7
B Requesting VBA code to make Outlook prompt for confirmation when deleting a task? Outlook VBA and Custom Forms 4
P How to get a QR code for automatic signin with Outlook for iOS Using Outlook 5
S HTML Code Embedded in String Within Open Outlook Email Preventing Replace(Application.ActiveInspector.CurrentItem.HTMLBody From Working Outlook VBA and Custom Forms 4
P Color Code or highlight folders in Outlook 2016 Using Outlook 2
B Outlook 2016 Unable to view images or logos on the outlook 2016 emails the same html code works well when i use outlook 2010 Using Outlook 0
S Excel vba code to manage outlook web app Using Outlook 10
S Outlook VBA How to adapt this code for using in a different Mail Inbox Outlook VBA and Custom Forms 0
I Outlook 2003 shows html code when To: field is empty Using Outlook 7
B Outlook Business Contact Manager with SQL to Excel, User Defined Fields in BCM don't sync in SQL. Can I use VBA code to copy 1 field to another? BCM (Business Contact Manager) 0
A VBA Code in Outlook disappears after first use Outlook VBA and Custom Forms 1
Z Outlook Custom Form: Adding Dropdown(Project Code) at the end of subject Outlook VBA and Custom Forms 0
dyny723 Outlook 2016: Code to link a contact to emails received from that contact Outlook VBA and Custom Forms 1
M code to move selected Outlook contacts to another folder Using Outlook 3
E Outlook Form - Voting Responses Not Auto Processing If Form Contains Any Code Outlook VBA and Custom Forms 0
C Need VBA code to automatically save message outside outlook and add date Outlook VBA and Custom Forms 1
J Outlook 2010 VBScript editor does not run code at all Outlook VBA and Custom Forms 0
L Outlook 2007 Contact Form Code Not Working Using Outlook 20
M VBA Code to Restart Outlook on error Outlook VBA and Custom Forms 3
Z Default VBA code for extracting data from email (Outlook) to Excel? Outlook VBA and Custom Forms 1
M VBA Auto-Reply code for Two Mailboxes on one Outlook Session. Outlook VBA and Custom Forms 4
S Outlook 2010 I am getting error code 0x8DE00006 'the operation failed'. outlook 2010 send/receive progress Using Outlook.com accounts in Outlook 2
H Where to post code in Outlook Outlook VBA and Custom Forms 1
G Custom Form code not working - Outlook 2010 Outlook VBA and Custom Forms 2
Kelli VBA code for Outlook Using Outlook 1
Wotme code to run outlook add-in Using Outlook 1
S Outlook code to validate textbox value Using Outlook 1
M VBA Code to extract data from an Outlook Form Using Outlook 0
M VBA code needed to move from Outlook 2010 subfolder to Symantec Vault subfolde Using Outlook 0
C In need of VBA code to read / parse HTML - Outlook emails Using Outlook 0
L Outlook 2007 Code for Note Fields of Appointment Using Outlook 102
R Private Sub Application_ItemSend() -Cannot make this code work in Outlook 2013 Using Outlook 0
R [VBA] complicated(?) outlook events - need help with code Using Outlook 15
C Error Code -3253 Outlook for MAC Using Outlook 0
D Outlook Add-In That Calculates Time Based on Area Code Using Outlook 8
R how to get Outlook VBA code to work on the current folder Using Outlook 3
J VBA code can't be completely executed in outlook 2013 Using Outlook 0
P VBA Code being completely ignored by Outlook Using Outlook 7
M Updating VBA code from outlook 2007 to outlook 2010 Using Outlook 1
B How do I create and send mail in Outlook 2003 from code? Using Outlook 5
J Create or Import a Outlook Rule through C# code. Outlook VBA and Custom Forms 2
C compile error on previously functioning code outlook 2003 windows Outlook VBA and Custom Forms 1
J Executing Ribbon Command from Code Outlook 2010 Outlook VBA and Custom Forms 3
N why does vb not recognise outlook code? Outlook VBA and Custom Forms 1
D Code to clear certain fields in Outlook Form Outlook VBA and Custom Forms 7
H want to launch outlook with attachemnet for new mail with c# code Outlook VBA and Custom Forms 3
T forcing a rule when opening outlook via code Outlook VBA and Custom Forms 1
O Scheduled Task Fails running Code to send Outlook Mail from Excel. Outlook VBA and Custom Forms 9
A Accessing .pst folder in outlook using VBA Code Outlook VBA and Custom Forms 4
T Outlook setting through code(in >tools >options) Outlook VBA and Custom Forms 1

Similar threads

Back
Top