question

kurooon-1202 avatar image
0 Votes"
kurooon-1202 asked Viorel-1 commented

exec VBA form VBS not working


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
office-vba-devoffice-scripts-excel-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Viorel-1 avatar image
0 Votes"
Viorel-1 answered Viorel-1 commented

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.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

thank you for your advice !
Actually, I can execute in my local environment. But It's not worked in production...

I'll try to modify code myself !

Do you have any idea to execute from Web server ?

0 Votes 0 ·

To handle Excel files from services or Web servers, even if Excel is not present, maybe you can use any Excel library developed for these purposes (https://www.bing.com/search?q=free+excel+library). This requires some effort. The CreateTwinYAxisGraph function must be rewritten in C#, VB or other languages, depending on library.

0 Votes 0 ·