Error executing batch file in excel VBA windows

Error executing batch file in excel VBA windows



I was trying to execute a batch file via standard call shell() function.
This Batch file is project specific and created automatically for each project by an external application. Main function is to normalise around 40 files having statistical data used for my project. This data is being acquired form excel. While executing manually this takes around 30 seconds for the complete process and its working just fine.



When I try to access this using call shell function in VBA, It just pop up for like 2 seconds and outputs were not generated from Batch file.
I am attaching My sample code below used for this. I am just baby-stepping in VBA Macros. Please Excuse my coding practice.




Call Shell(Range("L8") & "DSTAT$.BAT")



Call Shell(Range("L8") & "DSTAT$.BAT")



I tried this also


`Dim Runcc
Runcc = Shell(Range("L8") & "DSTAT$.BAT", 1)`



Please let me know if any further information is required to sort this out.





You'll have to give us more information to work with...
– Marcucciboy2
Aug 23 at 19:19





What was the batch file meant to do other than run for a few seconds? Can you add a pause command to the end of the batch file? Providing examples of your code goes a long way in helping people understand what you are trying to do and how to help you. I'd recommend looking at the help center, particularly the How to create a Minimal, Complete, and Verifiable example section.
– DavidP
Aug 23 at 20:03


pause





Sorry David, Now I added more information to my query. Hope this helps. As I mentioned Batch file is being created specifically for each project that I am working on. Is there a better way than adding pause comment during each Project.
– Abhi
Aug 24 at 4:31


pause




1 Answer
1



Try


Dim waitOnReturn As Boolean: waitOnReturn = True
Dim windowStyle As Integer: windowStyle = 1

With CreateObject("WScript.Shell")
.Run Range("L8") & "DSTAT$.BAT", windowStyle, waitOnReturn
End With



I use this for converting PDFs to JPG with Irfanview on report_open in Ms-Access.



Stolen from vba WScript.Shell run .exe file with parameter





Thank you! But this doesn't help either. I am still having the same issue.
– Abhi
Aug 24 at 9:09





@Abhi Check path with Debug.Print Range("L8") & "DSTAT$.BAT" copy string from immediate window and paste to commandline, maybe wrong sheet is used as you refer to ActiveWorkbook.ActiveSheet implicit, avoid that!
– ComputerVersteher
Aug 24 at 9:51


Debug.Print Range("L8") & "DSTAT$.BAT"


ActiveWorkbook.ActiveSheet






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ