exec VBA form VBS not working

kurooon 1 Reputation point
2021-12-23T09:25:00.49+00:00

I tried to execute VBA from VBS from PHP.

~ image ~
<PHP> : exec( fileName.vbs) => <VBS> : Obj.Application.Run "CreateTwinYAxisGraph" => <VBA> : CreateTwinYAxisGraph

The function exec() and VBS worked, but VBA was not ...
And I tried to execute VBS on Command line, VBA function succeeded.
I want to know how to work.

Here is my code.

Dim Obj
Dim FilePath
Set Obj = WScript.CreateObject("Excel.Application")
Set ObjArgs = WScript.Arguments
FilePath = ObjArgs(0)
Obj.Visible = True
Obj.Application.DisplayAlerts = False
CreateObject("WScript.Shell").AppActivate Obj.Caption
Set excel = Obj.Workbooks.Open(FilePath)
Obj.Application.Run "CreateTwinYAxisGraph"
excel.Save
excel.Close
Obj.Quit
Set excel = Nothing
Set Obj = Nothing
Microsoft 365 and Office Development Other
Developer technologies Visual Basic for Applications
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 122.5K Reputation points
    2021-12-23T11:43:22.463+00:00

    It seems that you are trying to use Excel from Web server, however this is not a designed usage of Office: https://support.microsoft.com/en-us/topic/considerations-for-server-side-automation-of-office-48bcfe93-8a89-47f1-0bce-017433ad79e2.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.