#1
|
|||
|
|||
Set font for body of calendar item through VBA?
Dim olAppt As Outlook.AppointmentItem Dim olApptCopy As Outlook.AppointmentItem Set olApptCopy = Outlook.CreateItem(olAppointmentItem) 'Copy the desired details to a new appointment item If objItem.Class = olAppointment Then Set olAppt = objItem With olApptCopy .Subject = olAppt.Subject .Location = olAppt.Location .Body = olAppt.Body .Categories = olAppt.Categories .AllDayEvent = olAppt.AllDayEvent End With 'Display the copy olApptCopy.Display This code takes a copy of a calendar item and copies it like a template for a new calendar item. It works really well. Now I would like to change the font from within the code. Is it possible? |
#2
|
||||
|
||||
That's simple enough. I demonstrated how to access the body of the appointment in my reply to your barcode issue.
Code:
Sub CopyItem() 'Graham Mayor - https://www.gmayor.com - Last updated - 05 Apr 2021 Dim olApptCopy As Outlook.AppointmentItem Dim objItem As Object Dim olInsp As Outlook.Inspector Dim wdDoc As Object Dim oRng As Object On Error Resume Next Select Case Outlook.Application.ActiveWindow.Class Case olInspector Set objItem = ActiveInspector.currentItem Case olExplorer Set objItem = Application.ActiveExplorer.Selection.Item(1) End Select Set olApptCopy = Outlook.CreateItem(olAppointmentItem) 'Copy the desired details to a new appointment item If objItem.Class = olAppointment Then With olApptCopy .Subject = objItem.Subject .Location = objItem.Location .Body = objItem.Body .Categories = objItem.Categories .AllDayEvent = objItem.AllDayEvent Set olInsp = .GetInspector Set wdDoc = olInsp.WordEditor Set oRng = wdDoc.Range 'set font for the body text oRng.Font.Name = "Times New Roman" oRng.Font.Size = "14" .Display End With End If Set olApptCopy = Nothing Set objItem = Nothing Set olInsp = Nothing Set wdDoc = Nothing Set oRng = Nothing End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
This code doesnt work for me either. When clicked, nothing happens.
I notice your code is calling for 'olInsp.WordEditor" Could I be missing an Add-in or the WordEditor ? |
#4
|
||||
|
||||
The Word Editor is what Outlook uses to edit the body texts.
However, I have just noticed that your profile suggests Office 2003 and Windows XP. The code suggestions will not work with those ancient products.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
|||
|
|||
My OS is Windows 10 Professional
I have two versions of MS Office installed. I have Office 2010, and the newest versions of Office 365 installed. I use Office 10 for Windows Outlook. I like it a lot better than the newer version where everything looks like a web page. I use both versions of Excel, and only the newest version of word. |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Add Calendar Item to Quick Access Toolbar | komobu | Outlook | 3 | 11-07-2020 03:04 PM |
Insert Excel Table into Outlook Calendar Item | komobu | Outlook | 0 | 02-07-2019 08:54 AM |
How to change the body font in an existing Design Template? | Meenie50 | Word | 2 | 01-04-2017 03:17 PM |
VBA to change font colour in email body on send | RealmOfCOnfusion | Outlook | 1 | 06-30-2016 09:55 PM |
Create Calendar Item though VBA | komobu | Outlook | 3 | 11-19-2015 08:44 AM |