|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?FreeOZ用户注册
x
本帖最后由 MICHELLE07 于 1-7-2015 09:13 编辑
关于Excel VBA的帖在这里。https://hioz.im/ibbs/thread-1131178-1-1.html
(但愿FreeOZ数据可以长久保存,至今还是觉得这里最方便 )
没精力从头整理由浅至深了,想到什么写什么。
按Shift 打开一个成品access文件后(或直接打开后点F11),可以看到所有的objects, 包括tables, queries, forms, reports, 以及 modules.
tables存取数据。
queries可以通过wizard 简单产生,也可以用各种expression. queries用的是SQL-standard query language
forms是操作界面,可以指向table, queries,reports, 也有自身的计算功能,最强大便捷的是通过控件运作宏
reports也有公式
modules我理解为一种宏,就是单独定义一串动作,而不需要重复写code
我的理解:用Microsoft Office(word, excel, outlook, access 等等)软件时,跳过普通应用界面,通过运行后台code 来实现批量操作或者达到某些特定功能,这种应用就叫VBA,不是真正的编程,还是用现成的东西,
但有基础programming 的性质。怎么写code,可以通过各种实例来了解。
发邮件
module的实例:
Sub SendMessage(DisplayMsg As Boolean)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim mydate
mydate = [Forms]![f_production].pDate
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("P&L-to")
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("P&L-cc")
objOutlookRecip.Type = olCC
' Add the BCC recipient(s) to the message.
' Set objOutlookRecip = .Recipients.Add("Andrew Fuller")
' objOutlookRecip.Type = olBCC
' Set the Subject, Body, and Importance of the message.
.Subject = "Production Reports for week ending " & mydate
.Body = "Please find the reports attached." & vbCrLf & vbCrLf
' .Importance = olImportanceHigh 'High importance
' Add attachments to the message.
.Attachments.Add ("\\server01\Admin_Data\Accounts\Michelle\***\***.pdf")
.Attachments.Add ("\\server01\Admin_Data\Accounts\Michelle\***\***.pdf")
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next
' Should we display the message before sending?
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing
End Sub
DoCmd.SendObject acSendReport, "r_p_order", acFormatPDF, sEmail, , "accounts@xxxx.com.au", "Purchase Order", , True
|
评分
-
查看全部评分
|