「Libreoffice VBA」:修訂間差異

出自TSK WIKI
跳至導覽 跳至搜尋
Root​(留言 | 貢獻)
Root​(留言 | 貢獻)
第27行: 第27行:
  Dim Dummy()
  Dim Dummy()
  sUrl = "file:///C:/test/test.odt" 」
  sUrl = "file:///C:/test/test.odt" 」
  Doc = StarDesktop.loadComponentFromURL(sUrl, "_blank", 0, Dummy()) '開啟新檔
  Doc = StarDesktop.loadComponentFromURL(sUrl, "_blank", 0, Dummy())  
  End Sub 
  End Sub 
==參考資料==
==參考資料==
[http://www1.cpshs.hcc.edu.tw/leson/learn/ASP%E8%B3%87%E6%96%99%E5%BA%AB/new_page_8.htm 資料庫連接]
[http://www1.cpshs.hcc.edu.tw/leson/learn/ASP%E8%B3%87%E6%96%99%E5%BA%AB/new_page_8.htm 資料庫連接]

於 2014年11月14日 (五) 09:06 的修訂

相容指令

Option VBASupport 1

SQL輸入範例

Option VBASupport 1
Private Sub CommandButton1_Click()
   Dim I As Integer
   Dim cn As New ADODB.Connection
   Dim strCn As String, strSQL As String    
   strCn = "Provider=sqloledb;Server=192.168.1.xx;Database=DEMO;Uid=xx;Pwd=xxxx;"    
   cn.Open strCn
   I = 2
   Do While Cells(I, 1) <> ""
       strSQL = "UPDATE PURTD set TD012='" & Range("E" & I) & "' where TD001='" & Range("A" & I) & "' and TD002='" & Range("B" & I) & "' 
       and TD003='" &    Range("C" & I) & "'"
       '底下寫執行sql語法
       cn.Execute strSQL
       I = I + 1
   Loop
   cn.Close    
   Set cn = Nothing
   MsgBox "執行完成"
End Sub

開舊檔案

Sub Main
Dim Doc As Object
Dim sUrl As String
Dim Dummy()
sUrl = "file:///C:/test/test.odt" 」
Doc = StarDesktop.loadComponentFromURL(sUrl, "_blank", 0, Dummy()) 
End Sub 

參考資料

資料庫連接