导航

2005年11月7日

摘要: VBA中初始化ADO连接的几种方法有以下几种:   1.通过CreateObject方法来创建连接,具体代码如下:    Dim conn1    Set conn1 = CreateObject("ADODB.Connection.2.0")   2.通过使用Dim ... as ...方法来创建连接    Dim conn2 As ADODB.Connection    Set conn2 = New ADODB.Connection   3.通过使用Dim ... as ... New的方法来创建连接    Dim conn3 As new ADODB.Connection    CreateObject方法比DIM方法速度要慢,其好处是你不需要在工程中引用ADO对象。 阅读全文

posted @ 2005-11-07 23:26 yunbo 阅读(828) 评论(0) 推荐(0) 编辑

摘要: Sub ConnDat()Sub ConnDat() \' \' ConnDat Macro \' ShaoSiMin 记录的宏 2002-8-25 \' Dim conn As Connection Dim rs As Recordset \'连接 SQL SERVER 数据库 Set conn = New Connection conn.Open "PROVIDER=SQLOLEDB;DATA SOURCE=SHAO4;User ID=sa;Password=12345;DataBase=DF" \'打开表 Set rs = New Recordset rs.Open "员工", conn, adOpenForwardOnly, adLockReadOnly \'关闭表和数据库 rs.Close conn.Close Set rs = Nothing Set conn = Nothing End Su 阅读全文

posted @ 2005-11-07 23:15 yunbo 阅读(1688) 评论(1) 推荐(0) 编辑

摘要: Option Explicit Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, _ ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, _ ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Private Sub Command1_Click() ShellExecute Me.hwnd, "open", "c:a.doc", vbNullString, vbNullString, 3 End Sub Private Sub Command2_Click() Dim WordApp As Word.Application 阅读全文

posted @ 2005-11-07 23:03 yunbo 阅读(782) 评论(0) 推荐(0) 编辑