作者:乔山办公网日期:
返回目录: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编一下。