2015-05-20 91 views
0

我想用VBA代碼編輯OFT編輯OFT用VBA代碼

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) 

With oMail 
    'strFind = "Code:" 
    'strNew = "Code:" & Cells(4, 3) ' for example 
    .HTMLBody = Replace(oMail.HTMLBody, strFind, strNew) 

    .Display 

End With 

End Sub 

這是我得到一個錯誤287(我SYSTEME是法語)

.HTMLBody = Replace(oMail.HTMLBody, strFind, strNew) 

人有線索?

回答

0

確保您設置了格式良好的HTML標記。例如:

With oMail 
    'Set body format to HTML 
    .BodyFormat = olFormatHTML 
    .HTMLBody = "<HTML><BODY>Enter the message text here. </BODY></HTML>" 
    .Display 
End With 

調用Replace方法,您也可以替換一些HTML標記。