VBA for the 2007 Microsoft(R) Office System

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。 http://blog.csdn.net/topmvp - topmvp
Develop your VBA expertise instantly with proven techniques

VBA for the 2007 Microsoft® Office System shows you how to take full advantage of the 2007 Microsoft Office suite by automating routine Office tasks. No matter which Office application youre using, there are some tasks you perform dozens of times, such as typing a section of text, running a series of menu commands, or formatting a document in a particular way.This book shows you how to accomplish the same tasks by incorporating them into a macro that you can run with just a few mouse clicks or keystrokes. This book shows you the basics of VBA programming from the ground up. Even if youve never programmed before, VBA for the 2007 Microsoft® Office System will have you up to speed with VBA in no time.Youll learn how to write programs that control Word, Excel, PowerPoint, Access databases, and even Outlook email.You get dozens of example macros that not only illustrate the concepts in the book but also provide you with practical, business-oriented tools that you can use right away to improve your productivity.

*Practical, real-world examples for anyone who uses Office applicationsnot just power users.
*Automate or streamline all your repetitive Word, Excel, and PowerPoint chores.
*Create custom dialog boxes and custom Ribbon tabs, groups, and buttons to make Office look and work the way you want it tono program experience required!
*Easy-to-understand instructions that make learning VBA fast and fun.
*All code examples and documents are available online so you can get started with VBA with a minimum of fuss.
*Automate Routine Tasks
*Control Word, Excel,and PowerPoint *Program Access Databases
*Automate Document Backups
*Create Advanced Email Rules
*Build Custom Dialog Boxes
*Customize the Office 2007
*Ribbon
*Access the Registry
*Troubleshoot Macro Problems

http://rapidshare.com/files/33461333/0789736675.rar
http://depositfiles.com/files/926632
谈到宏,很多人想到的是宏病毒,其实如果有正版杀毒软件,打开了实时防护,设置好宏安全性,可以利用宏来完成许多办公自动化功能。   打开word软件,从文件主菜单中“工具”->“宏”->“安全性”,设置安全性为中,这样就可以选择执行宏。安装office的时候,应该定制安装,在“office 工具”里选上“Visual Basic帮助”,这样就能获得非常完善的关于VBA编程环境、VBA语言参考、VBA对象等的帮助文档。从“工具”->“宏”->“Visual Basic 编辑器”可以打开VBA编程环境——“Microsoft Visual Basic”。在编程环境中打开“帮助”->“Microsoft Visual Basic帮助”,就可以看到帮助了。   很多人觉得学习Visual Basic没有用,事实上,Visual Basic系列的编程语言包括VB、VBA、VBScript等,可以写网页、办公自动化编程、应用编程。在一些其他公司的应用软件中也是可以用VBA的,例如Corel Draw。这里举几个例子来说明VBA的使用。   如果有数十个文档需要合并为一个文档,逐个打开、拷贝是件麻烦事,可以用宏来完成。 例一:合并文档。新建一个窗体,窗体上放一个按钮。工具箱可以从“视图”->“工具箱”打开。 '按钮事件 Private Sub CommandButton1_Click() Dim sPath As String 'sPath用来保存路径 Dim tem As String '中间变量 Set newDoc = Documents.Add '用Documents.Add增加一个新文档 With newDoc .SaveAs FileName:="D:/txtal.doc" '新文档保存的完整路径 End With ActiveDocument.close '关闭新建的文档 With Dialogs(wdDialogFileFind) '设置文本查找对话框 .SortBy = 2 '文件按名称排列 .SearchName = "*.txt" '只列出文本文件 .Update '更新 End With If Dialogs(wdDialogFileFind).Show = -1 Then '如果按下打开,就执行 sPath = Dialogs(wdDialogFileFind).SearchPath '将查找对话框打开的路径附值给SPath Dialogs(wdDialogFileFind).Execute Else Exit Sub '如果取消或者关闭,就退出 End If With Application.FileSearch '设置应用程序的查找 .NewSearch '新查找 .LookIn = sPath '将新查找的路径设置为文件对话框的路径(sPath) .SearchSubFolders = True '查找子目录 .FileType = msoFileTypeAllFiles '查找所有文件类型,这里可以设置其他类型,具体见FileSearch对象的FileType属性 .FileName = "*.txt" '查找后缀为txt的文件 .Execute '执行文件查找 Documents.Open ("D:/txtal.doc") '打开"D:/txtal.doc" Set Range2 = ActiveDocument.Content '设置Range2对象为活动文档的内容 For i = 1 To .FoundFiles.Count '把找到的文件打开,拷贝文件内容,加到新建的D:/txtal.doc文件中 Documents.Open (.FoundFiles(i)) '打开第i个找到的文件 ActiveDocument.Content.Select '全选活动文件的内容 Selection.Copy '拷贝选中的内容 ActiveDocument.Close '关闭活动文档 Range2.Collapse Direction:=wdColla
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值