Results 1 to 5 of 5

Thread: Editing OFT from Excel

  1. #1

    Question Editing OFT from Excel



    Register for a FREE account, and/
    or Log in to avoid these ads!

    I'm trying to edit an OFT from excel with a Command Button. I'm able to open the OFT but not to edit it.

    The Replace didnt work (error 287)

    Code:
    Private Sub CommandButton1_Click()
    
    template = "T:\Coordination des interventions\Coordination des changements\Communications\Interruption de service planifiée - Environnements applicatifs Oracle - Copie.oft"
    strNew = InputBox("Jour de la semaine")
    strFind = ">JourSemaine<"
    
    
    Dim oApp As Object, oMail As Object
    
    Set oApp = CreateObject("Outlook.Application")
    Set oMail = oApp.CreateItemFromTemplate(template)
    
    
    oMail.HTMLBody = Replace(oMail.HTMLBody, strFind, strNew)
    
    oMail.Display
    
    
    End Sub
    Someone can help me?

  2. #2
    Conjurer snb's Avatar
    Join Date
    May 2013
    Posts
    376
    Articles
    0
    Excel Version
    2020
    What is the result in the msgbox ?


    Code:
    Private Sub CommandButton1_Click()
      template = "T:\Coordination des interventions\Coordination des changements\Communications\Interruption de service planifiée - Environnements applicatifs Oracle - Copie.oft" 
       strNew = InputBox("Jour de la semaine") 
       strFind = ">JourSemaine<"  
     
       Dim oApp As Object, 
       oMail As Object  
     
       Set oApp = CreateObject("Outlook.Application") 
       Set oMail = oApp.CreateItemFromTemplate(template)
    
       msgbox oMail.HTMLBody
    
    'oMail.HTMLBody = Replace(oMail.HTMLBody, strFind, strNew)  
    'oMail.Display 
    
    End Sub

  3. #3
    same error 287 (Application-defined or object-defined error)

  4. #4
    Conjurer snb's Avatar
    Join Date
    May 2013
    Posts
    376
    Articles
    0
    Excel Version
    2020
    In that case the template doesn't exist or it's fullname has been misspelled.

    test:

    Code:
    Sub M_tst()
       msgbox dir("T:\Coordination des interventions\Coordination des changements\Communications\Interruption de service planifiée - Environnements applicatifs Oracle - Copie.oft"
    End Sub


  5. #5
    It's not the template. If i remove de replace line, the template is well displayed in Outlook


    Code:
    'oMail.HTMLBody = Replace(oMail.HTMLBody, strFind, strNew)
      oMail.Display

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •