Outlook template

josros60

Well-known Member
Joined
Jun 27, 2010
Messages
786
Office Version
  1. 365
Hi,

I have these codes in outlook for template selection but giving me this error in:

Case 0, Case 1, and Case 3, this is the error: (I checked names for misspelling and are correct)

Run-Time error '-2147287038 (30030002)':
we can't open
c:\users\....................


Form Code:

VBA Code:
Option Explicit

Private Sub UserForm_Initialize()
    With Combobox1
        
        
        
        
    .AddItem "NCL-PRIMUS USD WIRE(S) FOR THE WEEK OF_BATCH"
    .AddItem "NCL-PRIMUS CAD WIRE(S) FOR THE WEEK OF_BATCH"
    .AddItem "NCL-PRIMUS EFT FOR THE WEEK OF_BATCH"
    .AddItem "NCL-PRIMUS ONLINE PAYMENTS FOR THE WEEK OF_BATCH"
    .AddItem "BANKING INFORMATION REQUEST"
    .AddItem "BC HYDRO EFT REMITTANCE"
    
        
           
        
        
        
    End With
End Sub

Private Sub btnOK_Click()

   lstNum = Combobox1.ListIndex
   'With Me.Combobox1
    'MsgBox "Index number = " & lstNum & "; Value = " & .Value
    'End With
    Unload Me
End Sub

Macro code to run Templates:

VBA Code:
Option Explicit

Public lstNum As Integer

Public Sub ChooseTemplate()

    Dim oMail As Outlook.MailItem
    Dim strTemplate As String
    
    UserForm1.Show
    
    Select Case lstNum
       
     Case -1
'  -1 is what you want to use if nothing is selected

         strTemplate = "NCL-PRIMUS USD WIRE(S) FOR THE WEEK OF_BATCH"
    Case 0
         strTemplate = "NCL-PRIMUS USD WIRE(S) FOR THE WEEK OF_BATCH"
    Case 1
        strTemplate = "NCL-PRIMUS CAD WIRE(S) FOR THE WEEK OF_BATCH"
    Case 2
         strTemplate = "NCL-PRIMUS EFT FOR THE WEEK OF_BATCH"
    Case 3
         strTemplate = "NCL-PRIMUS ONLINE PAYMENTS FOR THE WEEK OF_BATCH"
    Case 4
         strTemplate = "BANKING INFORMATION REQUEST"
         
    Case 5
         strTemplate = "BC HYDRO EFT REMITTANCE"
        
 
     
               
              
    End Select
    
    
   
    
    strTemplate = "C:\Users\jose.rossi\AppData\Roaming\Microsoft\Templates\" & strTemplate & ".oft"
    
    Set oMail = Application.CreateItemFromTemplate(strTemplate)
       
    oMail.Display
   
 


  
Set oMail = Nothing

    Set oMail = Nothing
    
End Sub


thank you
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,223,707
Messages
6,174,000
Members
452,542
Latest member
Bricklin

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