Dim xlApp a" />
乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > <em>Outlook</em> VBA调用excel函数

<em>Outlook</em> VBA调用excel函数

作者:乔山办公网日期:

返回目录:excel表格制作


可以啊,把你想做的东西给我发个附件,我帮你搞定!

我的邮箱 我不要你的分,只是为了互相帮助.

Dim xlApp as Object
set xlapp = CreateObject("Excel.Application")
'注意这里必须确认“某工作簿”已经打开,否则下面的代码依然会出错!
'通常情况下我会这么做:
Dim wb as object
For wb in xlapp.Workbooks
    if wb.name = "某工作不.xls" then Goto WbHasOpened
next
set wb = xlapp.Workbooks.Open("某路径\某工作不.xls")
WbHasOpened:
Art = xlapp.Worksheetfunction.Substitute(wb.Sheets("工作表名").Cells(1, 1), " ", "")

Sub sendmail()
Dim rowCount,
endRowNo
Set objOutlook =CreateObject("Outlook.Application")
Set objMail =objOutlook.CreateItem(olMailItem)
Set objMail =objOutlook.CreateItem(olMailItem)
With objMail
.To = Cells(1,2).Value'替换为邮件地址
.Subject = Cells(2,2).Value'替换为邮件主题
.Body = Cells(3,2).Value'替换为邮件内容
.Attachments.Add ThisWorkbook.FullName'替换为附件
.Send
End With
Set objMail =Nothing
Set objOutlook =Nothing
End Sub

如果是多人的话,可以加一个循环,不懂可以问我。



Public Function InsertToTransact(strUID As String, strText As String, strTran As String, strSpecial As String) As Boolean
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strAccess As String
strAccess = "D:\VBA Work\OutLook\DataBase\Application Record.mdb"

On Error GoTo ErrorHandle

Set cnn = New ADODB.Connection
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open strAccess
End With

Set rst = New ADODB.Recordset
rst.CursorLocation = adUseServer

rst.Open Source:="Transact_Record", _
ActiveConnection:=cnn, _
CursorType:=adOpenDynamic, _
LockType:=adLockOptimistic, _
Options:=adCmdTable

rst.AddNew
rst("UID") = strUID
rst("MailDatetime") = Format(Now, "YYYY-MM-DD hh:mm:ss")
rst("MailContent") = strText
rst("bTransact") = strTran
rst("Sepecial_ID") = strSpecial
rst.Update

rst.Close
cnn.Close

Set rst = Nothing
Set cnn = Nothing
If ControlTxtFile("Date", g_strPath_Date, "InsertToTransact-----Success!") Then

End If
Exit Function
ErrorHandle:
'rst.Close
cnn.Close
If ControlTxtFile("Date", g_strPath_Date, "InsertToTransact-----Failure!") Then

End If
Set rst = Nothing
Set cnn = Nothing
'MsgBox "Update failure!"
End Function

这个是一个例子,可以UPDATE数据库,但是你需要查询的话更简单,你可以用上面的代码改e69da5e6ba90e79fa5e98193365编一下。

相关阅读

  • <em>Outlook</em> VBA调用excel函数

  • 乔山办公网excel表格制作
  • 可以啊,把你想做的东西给我发个附件,我帮你搞定!我的邮箱 我不要你的分,只是为了互相帮助.outlook的vba怎样读取excel的数据" src="/uploads/tu/171.jpg" style="width: 400px; height: 267px;" />Dim xlApp a
关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网