Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-04-2021, 01:05 PM
komobu komobu is offline Set font for body of calendar item through VBA? Windows XP Set font for body of calendar item through VBA? Office 2003
Advanced Beginner
Set font for body of calendar item through VBA?
 
Join Date: Feb 2011
Posts: 34
komobu is on a distinguished road
Default 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?
Reply With Quote
  #2  
Old 04-04-2021, 08:53 PM
gmayor's Avatar
gmayor gmayor is offline Set font for body of calendar item through VBA? Windows 10 Set font for body of calendar item through VBA? Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #3  
Old 04-06-2021, 06:10 AM
komobu komobu is offline Set font for body of calendar item through VBA? Windows XP Set font for body of calendar item through VBA? Office 2003
Advanced Beginner
Set font for body of calendar item through VBA?
 
Join Date: Feb 2011
Posts: 34
komobu is on a distinguished road
Default

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 ?
Reply With Quote
  #4  
Old 04-06-2021, 08:33 PM
gmayor's Avatar
gmayor gmayor is offline Set font for body of calendar item through VBA? Windows 10 Set font for body of calendar item through VBA? Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #5  
Old 04-07-2021, 05:36 AM
komobu komobu is offline Set font for body of calendar item through VBA? Windows XP Set font for body of calendar item through VBA? Office 2003
Advanced Beginner
Set font for body of calendar item through VBA?
 
Join Date: Feb 2011
Posts: 34
komobu is on a distinguished road
Default

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.
Reply With Quote
Reply

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
Set font for body of calendar item through VBA? How to change the body font in an existing Design Template? Meenie50 Word 2 01-04-2017 03:17 PM
Set font for body of calendar item through VBA? VBA to change font colour in email body on send RealmOfCOnfusion Outlook 1 06-30-2016 09:55 PM
Set font for body of calendar item through VBA? Create Calendar Item though VBA komobu Outlook 3 11-19-2015 08:44 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:12 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft