Page 1 of 1

[Solved] Execute .vbs file using macro in Calc

Posted: Tue Nov 05, 2024 2:16 pm
by Lovepreet323
Please advise how to run or execute (.vbs) file using calc macro

(.bat) file ruining very well using below code, but (.vbs) file not running
SysShell.Execute(ABC.bat,CmdString,0)

Re: Execute .vbs file using macro in Calc

Posted: Wed Nov 06, 2024 6:43 am
by Zizi64
The .bat files requests the operating system only, but - I suppose it - the .vbs files requests some Visual Basic interpreter.

https://stackoverflow.com/questions/690 ... xecute-vbs

Re: Execute .vbs file using macro in Calc

Posted: Wed Nov 06, 2024 9:32 am
by Mr.Dandy
Be sure that soffice process has sufficiant rights to run .vbs script.
Especially if you're running functions on the operating system.

Re: Execute .vbs file using macro in Calc

Posted: Thu Nov 07, 2024 8:37 am
by Lovepreet323
How to give rights to soffice to run .vbs file

Re: Execute .vbs file using macro in Calc

Posted: Thu Nov 07, 2024 4:30 pm
by Mr.Dandy
Lovepreet323 wrote: Thu Nov 07, 2024 8:37 am How to give rights to soffice to run .vbs file
You must launch your VBscript in Elevated mode
Ask to your prefered MS forum

But for me, this is an XY problem. Why using an external program?

Re: Execute .vbs file using macro in Calc

Posted: Thu Nov 07, 2024 4:42 pm
by Lovepreet323
I made a vbs script to download a file from web in hidden mode without using any browser. Because i unable hide downloding from browser

Re: Execute .vbs file using macro in Calc

Posted: Sat Nov 09, 2024 11:35 am
by ms777
... if it is just about downloading a file I would recommend to use OOBasic rather than VBS

Code: Select all

oSimpleFileAccess = createUnoService("com.sun.star.ucb.SimpleFileAccess")
oSimpleFileAccess.copy("https://www.google.de", "C:\users\martin\downloads\google.html")

Re: Execute .vbs file using macro in Calc

Posted: Mon Nov 11, 2024 9:00 am
by Lovepreet323
Please provide complete macro code of above example

Re: Execute .vbs file using macro in Calc

Posted: Mon Nov 11, 2024 10:49 am
by RoryOF
For information: many examples of suitable macro code for OpenOffice and LibreOffice, together with an informative discussion on such programming are in the works of Andrew Pitonyak, which may be downloaded free from his site at

https://www.pitonyak.org/oo.php

Re: Execute .vbs file using macro in Calc

Posted: Mon Nov 11, 2024 11:38 am
by ms777
This is the complete code. You just have to replace the target web file you want to download and the target storage location
(and add sub main / end sub)

Re: Solved **Execute .vbs file using macro in Calc

Posted: Mon Nov 11, 2024 2:32 pm
by Lovepreet323
Thanks all above who helped me. It's working very well👍

Re: [Solved] Execute .vbs file using macro in Calc

Posted: Mon Nov 11, 2024 3:56 pm
by Lovepreet323
Please help me to solve one more issue to download file in download folder with default or randomly name as file name daliy changed and don't want to change the name of file
Sourepath correctly worked but Destinationpath not working
Sourepath = A1
Destinationpath =B2
oSimpleFileAccess.copy(Sourcepath, Destinationpath)

Re: [Solved] Execute .vbs file using macro in Calc

Posted: Mon Nov 11, 2024 4:34 pm
by Zizi64
Please upload your ODF type sample file here. Then we will able to examine the URL/Path syntax. (What string is located in the cells?)