To access OLE object inserted to an excel sheet

sugaprasad

New Member
Joined
Sep 4, 2013
Messages
9
hello,

I am building a macro using excel VBA.

Objective of the macro is to send out mails using a particular standard template. I saved the template to a local folder in my computer and written the code. It works just fine.

But the requirement changed all of a sudden. Now I need to attach that template into the excel sheet (Insert --> Object--> create from file ) and use that as a source (say I am attaching the template as an object in Sheet3)

So now my question is, How to access the object (outlook template) which is attached in the excel sheet as a source template and send out mails

My code for your reference.


<code style="margin: 0px; padding: 0px; font-style: inherit;">
Code:
Dim OutApp As Object
    Dim Itm As Object

    Set OutApp = CreateObject("Outlook.Application")
   Set Itm = OutApp.CreateItemFromTemplate("C:\Users\sun\Desktop\format1.oft")  '(this needs to be accessed from the excel itself not from local folder)

          With Itm
                .To = "abc@def.com"
                .Subject = "Subject"
                .Body = "Txt goes here"
                .Send 
            End With


Thank you in advance

Raised the same question in another forum too. Link
</code>
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,223,214
Messages
6,170,774
Members
452,353
Latest member
strainu

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