作者:乔山办公网日期:
返回目录:office365
旧版本的VBA裏面要改一些代码,才能在2013裏面用,636f7079e79fa5e98193362如我的代码:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
要改成:
Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal Hwnd As Long, ByVal nIndex As Long) As Long
Private Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal Hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
好像多了“PtrSafe”字。
VBA 是 Office 常见套件的母语,不是说换就换的,就好比 N 年前发明的自行车,抄在这个汽车流行的时代依然存在,这至少说明了一点:经典的东西自然有其自身存在的价值。
当使用 VBA 做出来的功能满足不了我们需求的时候,我们可以考虑用 VSTO (Visual Studio Tools for Office) 来开发,而在 VSTO 的开发中就有两种常见的语言,他们是:VB.NET、C#。VB.NET 和 VBA 都属于 Basic 语言家族的,所以他们有相似之处。
PS:
在 .NET 中有 WebService,在 Excel 2013 中也可以方便的调zd用 WorksheetFunction.WebService,但是在 Excel 2013 以前的版本中是没有的,从这点可以看出,微软还是在不断的加强和完善新版 Office 组件中的 VBA 功能。
VBA与SQL的结合百,其实和VBS(就是ASP)差不多的,举个例子度:
Set cnn = CreateObject("ADODB.Connection")
cnn.Provider = "Microsoft.Jet.OLEDB.4.0"
cnn.Open ThisWorkbook.Path & "\Access数据库\DATA.mdb"
strSQL="SELECT * FROM test"
msgbox cnn.Execute(CommandText:=strSQL).GetString
还可以GetRows方法返回问数组。
希望答例子对你有帮助,怎么把结果存到专EXCEL表格,网上例子一大堆属。
移动版(RT)取消了抄vba,桌面电脑仍然存在
如果你安装了office2013,而没有找到VBA,那是因为微软把他藏起袭来了,并且默认禁用宏
打开方法:
文件 --> 选项 --> 自定义功能区 --> 右侧 开发工具 ,前zd面的勾打上 --> 确定!