首页 > 解决方案 > 在访问数据库中通过 html 修复单元格填充

问题描述

我目前在数据库中有一个代码,可以发送带有表格的电子邮件该表格当前的格式不正确,我无法应用单元格填充。有任何想法吗? 在此处输入图像描述

这是随附的代码

Function exporthtml()

Dim strline, strHTML, strMsg
Dim Cnt As String
Dim strFilt As String
Dim ACname As String
Dim filt As String
Dim strCC As String

Cnt = DCount("[PATS Action ID]", "tblPAT", "Bureau='" &    Form_frmMainPATS.cboBur.Value & "'")
ACname = DLookup("FIRSTNAME", "qryAC", "Bureau='" &   Form_frmMainPATS.txtFull.Value & "'")
strFilt = DLookup("WORKEMAIL", "qryAC", "Bureau='" &    Form_frmMainPATS.txtFull.Value & "'")
 Dim OL As Outlook.Application

 Set OL = New Outlook.Application
 Set MyItem = Outlook.Application.CreateItem(olMailItem)


 Report_rptCurrentPATS.Filter = "Bureau='" & Form_frmMainPATS.cboBur.Value & "'"
Report_rptCurrentPATS.FilterOn = True

DoCmd.OutputTo acOutputReport, "rptCurrentPATS", acFormatHTML, "R:\Epi- Admin\Administrative Collaboration\Admin Review Meetings\Weekly Administrative Reports\Working Documents\Bureau Status Report Updates\TEST.html"

Open "R:\Epi-Admin\Administrative Collaboration\Admin Review   Meetings\Weekly Administrative Reports\Working Documents\Bureau Status Report Updates\TEST.html" For Input As 1
Do While Not EOF(1)
Input #1, strline
strHTML = strHTML & strline
  Loop
Close 1
If Left(OL.Version, 2) = "10" Then
MyItem.BodyFormat = olFormatHTML
End If
MyItem.To = strFilt
MyItem.Subject = "Updated PATS Status Report as of " & Date - 1
MyItem.HTMLBody = "<BODY bgcolor='#E6E6FA'>" & "<img src='R:\Epi-Admin\Fiscal Management and Reporting Unit\Database\PS Database\logo.png' ALT='Banner'" & "<p>" & "<FONT color = '#000000'>" & "Dear " & ACname & "," & "<br/>" & "<br/>" & Form_frmMainPATS.cboBur.Value & " currently has " & Cnt & " pending personnel actions." & "</p>" & "<p>" & "Please see the report below:" & "<br/>" & "<BODY>" & "<table border= '1'>" & "<bgcolor=#ffffff; cellspacing=10; table-layout: fixed; >" & "<table header= '1' bgcolor='#fffff'>" & strHTML & "</table>" & "</br>" & "<br/>" & "</br>" & "</br>" & "<p> If you have any questions, please contact your desingated Personnel Coordinator"

MyItem.Display End Function 任何帮助将不胜感激

标签: htmlms-accessvba

解决方案


从上面扩展我的评论,您可以尝试看看这样的事情是否有效或让您朝着正确的方向前进(未经测试):

Dim strCell() as string

Do While Not EOF(1)
    Input #1, strline
    strCell() = Split(strline, vbTab) 'Replace vbTab with deliminator if needed

    dim i as integer

    for i = 0 to UBound(strCell)
        strline = "<td>" & strCell(i) & "</td>"
    next

    strHTML = strHTML & "<tr>" & strline & "</tr>"
Loop
Close 1

推荐阅读