Open *.oft file

Trevor3007

Well-known Member
Joined
Jan 26, 2017
Messages
667
Office Version
  1. 365
Platform
  1. Windows
Good evening,


I currently use this code:-

VBA Code:
Sub template()

    Dim theEmailAddress As String
    theEmailAddress = InputBox("Please enter an email address...", Title:="Email Address")
    
    If Len(theEmailAddress) = 0 Then Exit Sub 'user cancelled or omitted the email address
    
    'here you will need to validate the email address
    
    Dim newItem As MailItem
    Set newItem = Application.CreateItemFromTemplate("D:\work\template.oft")
    
    With newItem
    
        .Display
        
        .To = theEmailAddress
        
        .Body = "Hi " & Split(theEmailAddress, ".")(0) & "," & vbCrLf & vbCrLf & .Body
        
        .GetInspector.WordEditor.Application.Selection.endkey unit:=6 'optional (to position cursor after the salution)

    End With

I dont have te VB knowledge ( the above was created by someone who has). The above works fine but i ould like it only to open the *.oft file and not prompt for an eamil address to be inserted 1st then open the *. oft file ?

Or alternitively , keep the email request, but able to not enter a eamil address & just open the *.oft file Perhaps use a 'Yes No?

Thanks in advance & hope you can help.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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