facebook twitter hatena line email

Libreoffice/表計算/マクロphp連携

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

引数なしであれば実行できる

Sub TestPHPScript()
    Dim oShell As Object
    oShell = CreateUnoService("com.sun.star.system.SystemShellExecute")
    Dim sCmd As String
    Dim sArgs As String
    sCmd = "/opt/homebrew/bin/php"
    sArgs = "/d/www/php/test.php"
    oShell.execute sCmd, sArgs, 1
    MsgBox "called"
End Sub

引数ありだと失敗する

Sub TestPHPScript()
    Dim oShell As Object
    oShell = CreateUnoService("com.sun.star.system.SystemShellExecute")
    Dim sCmd As String
    Dim sArgs As String
    sCmd = "/opt/homebrew/bin/php"
    sArgs = "/d/www/php/test.php hello"
    oShell.execute sCmd, sArgs, 1
    MsgBox "called"
End Sub

エラーメッセージ詳細

BASIC runtime error.
An exception occurred 
Type: com.sun.star.system.SystemShellExecuteException
Message: Attribute not found.