Html 头部样式本机网络浏览器控制MSAccess 2013

Html 头部样式本机网络浏览器控制MSAccess 2013,html,vba,ms-access,webbrowser-control,stylesheet,Html,Vba,Ms Access,Webbrowser Control,Stylesheet,我将一些html字符串存储在备忘录字段中,存储在Microsoft Access内置的表数据库中 我在原生WebBrowser控件中显示这些html字符串(Access 2010/2013) 我想使用文档头部分的样式元素将简单的格式设置(字体系列、字体大小等)应用于这些html文档 With Me.WebBrowser6.Object .Navigate2 "about:blank" .Document.write rst.Fields(2) .Refresh End W

我将一些html字符串存储在备忘录字段中,存储在Microsoft Access内置的表数据库中

我在原生WebBrowser控件中显示这些html字符串(Access 2010/2013)

我想使用文档头
部分的样式元素将简单的格式设置(字体系列、字体大小等)应用于这些html文档

With Me.WebBrowser6.Object
    .Navigate2 "about:blank"
    .Document.write rst.Fields(2)
    .Refresh
End With
尝试了以下几点:

首先,我尝试将head部分直接添加到我的字符串中:

' strModified is just the body of a modified html document.

strModified = "<HTML><HEAD><style> " & _
              "html *{" & _
              "font-family:Calibri !important;" & _
              "font-size: 20pt !important;" & _
              "} " & _
              "</style></HEAD>" & strModified & "</HTML>"
Private Sub cboDescriptions_AfterUpdate()

    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("tblDescriptions")
    With rst
        .Index = "PrimaryKey"
        .Seek "=", Me.cboDescriptions
        Dim html As HTMLDocument
        Set html = Me.WebBrowser2.Object.Document
            With html
                Do While .ReadyState <> "complete": DoEvents: Loop
                .Head.Style.fontFamily = "Verdana"
                .Head.Style.FontSize = 20
                .body.innerHTML = rst.Fields(2)
            End With
        Set html = Nothing
    End With
    Set rst = Nothing
    Set dbs = Nothing

End Sub
最后,每次显示的文档更改时,我都尝试设置标题样式:

' strModified is just the body of a modified html document.

strModified = "<HTML><HEAD><style> " & _
              "html *{" & _
              "font-family:Calibri !important;" & _
              "font-size: 20pt !important;" & _
              "} " & _
              "</style></HEAD>" & strModified & "</HTML>"
Private Sub cboDescriptions_AfterUpdate()

    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("tblDescriptions")
    With rst
        .Index = "PrimaryKey"
        .Seek "=", Me.cboDescriptions
        Dim html As HTMLDocument
        Set html = Me.WebBrowser2.Object.Document
            With html
                Do While .ReadyState <> "complete": DoEvents: Loop
                .Head.Style.fontFamily = "Verdana"
                .Head.Style.FontSize = 20
                .body.innerHTML = rst.Fields(2)
            End With
        Set html = Nothing
    End With
    Set rst = Nothing
    Set dbs = Nothing

End Sub
Private Sub-cboDescriptions\u AfterUpdate()
Dim数据库作为DAO.Database
将rst设置为DAO.Recordset
设置dbs=CurrentDb
Set rst=dbs.OpenRecordset(“tblDescriptions”)
用rst
.Index=“PrimaryKey”
.Seek“=”,Me.cboDescriptions
将html设置为HTMLDocument
设置html=Me.WebBrowser2.Object.Document
使用html
Do While.ReadyState“complete”:DoEvents:Loop
.Head.Style.fontfamine=“Verdana”
.Head.Style.FontSize=20
.body.innerHTML=rst.Fields(2)
以
设置html=Nothing
以
设置rst=无
设置dbs=Nothing
端接头
我想问一下如何将标题样式添加到html字符串中,以便在浏览器控件中显示(本机或ActiveX),在MsAccess中

提前感谢,


Diego

我决定使用ActiveX WebBrowser控件,而不是Access 2010/2013的本机WebBrowser控件,因为前者接受html字符串,并使用文档的write属性正确格式化文档

With Me.WebBrowser6.Object
    .Navigate2 "about:blank"
    .Document.write rst.Fields(2)
    .Refresh
End With