---
Sub AddHTMLAndScriptExample(objOffDoc As Object)
Dim itmPrjItem As HTMLProjectItem
Dim strNewText As String
Dim strNewScript As String
Dim strNewHTML As String
strNewText = GetText()
strNewScript = GetScript()
Set itmPrjItem = objOffDoc.HTMLProject.HTMLProjectItems(1)
With itmPrjItem
strNewHTML = .Text
Call InsertHTMLText(strNewHTML, "<div class=Section1>", strNewText & vbCrLf & strNewScript)
.Text = strNewHTML
End With
End Sub
---
---
Public Function AddHTMLToPage(oDocument As Object, strHTMLtext As String, bClearPage As Boolean) As Boolean
' This function adds specified HTML content to the page specified in oDocument by creating a text range object
' from the oDocument.body object. If bClearPage is true the the entire content between <body> </body> is replaced
' otherwise the HTML is appended to the bottom of the current content, before the </body> tag
Dim r As Object, b As Object
On Error GoTo ecouldnotinserthtml
' get the textrange object
If bClearPage Then
Set r = oDocument.all.tags("BODY"

.Item(0).createTextRange
' clear out the current document
If bClearPage Then
Call r.pasteHTML(""

End If
r.collapse False
Set r = Nothing
End If
Set b = oDocument.all.tags("BODY"

.Item(0)
b.innerHTML = b.innerHTML + strHTMLtext + vbCrLf
AddHTMLToPage = True
Exit Function
ecouldnotinserthtml:
AddHTMLToPage = False
End Function
Sub TestIt()
Dim sHTMLString as String
sHTMLString = "<B> <I> FOOBAR </I> </B>" + vbcr
If AddHTMLToPage(ActivePageWindow.Document, sHTMLString, True) Then
Set myelem = ActivePageWindow.Document.all.tags("B"

.item(0)
End If
End Sub
--- Best Regards
---
JoaoTL
mail@jtl.co.pt
MS Access Site:
The Page:
moved to