paste clipboard to .body of outlook appointment

aspiringnerd

New Member
Joined
Apr 22, 2022
Messages
39
Office Version
  1. 365
Platform
  1. Windows
I have a function that copies a dynamic range to my clipboard, is it possible to set .body equal to my clipboard? I'm currently manually pasting it into the body of the outlook event

VBA Code:
Sub new_event()
    Set olOutlook = CreateObject("Outlook.Application")
    Set Namespace = olOutlook.GetNameSpace("MAPI")
    Set oloFolder = Namespace.GetDefaultFolder(9)
    
    
    Set Appointment = oloFolder.items.Add
    
    With Appointment
        .AllDayEvent = True
        .Start = Cells(ActiveCell.Row, "T").Value
        .End = Cells(ActiveCell.Row, "U").Value
        .Categories = Cells(ActiveCell.Row, "V").Value
        .Subject = Cells(ActiveCell.Row, "W").Value
        '.Body = selectandcopy 'selectandcopy is a function that copies a dynamic range my clipboard, im currently manualy pasting the clipboard, is it possible to automate this task?
        .Display
    End With
End Sub
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
I think it might be better to set .body equal to the range in selectandcopy rather than to try copy and pasting. I'll post the vba once I get it roughly in shape
 
Upvote 0
Here's what I've done so far, I commented where I get an error, if I comment it out, everything else works fine except I'm still manually copy and pasting the range (myrange)

VBA Code:
Sub test()
    Dim ws As Worksheet, LastRow As Long, myrange As Range

    Set ws = ActiveSheet
    LastRow = ws.Range("A" & ws.Rows.Count).End(xlUp).Row
    Set myrange = ws.Range("A2:H" & LastRow)
    
    Set olOutlook = CreateObject("Outlook.Application")
    Set Namespace = olOutlook.GetNamespace("MAPI")
    Set myRecipient = Namespace.CreateRecipient("recipient@outlook.com")
    Set oloFolder = Namespace.GetSharedDefaultFolder(myRecipient, 9)
    Set Appointment = oloFolder.items.Add
    
    With Appointment
        .AllDayEvent = True
        .Start = Cells(ActiveCell.Row, "T").Value
        .End = Cells(ActiveCell.Row, "U").Value
        .Categories = Cells(ActiveCell.Row, "V").Value
        .Subject = Cells(ActiveCell.Row, "W").Value
        .Body = myrange 'this gives me an error "the object does not support this method"
        .Display
        
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,255
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top