Libreoffice VBA
相容指令
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