Free Microsoft Excel 2013
Quick Reference
Free Microsoft 2013 Quick Reference Guide

Free Microsoft Excel 2013 Quick Reference

Running .exe files from Macro

Dear All,

How can I run a .exe file from a macro embedded in excel? Also, is it possible to take the output from that .exe file to a form?

Thanks


Post your answer or comment

comments powered by Disqus
Hi,
I have one exe which is executing successfully. I need to call this exe file from a user form in excel using macros. I am trying to call but its not working neither its giving any error.

If i try to call notepad.exe using excel macro it works but i can not understand why its not working for me. Any suggestions or links to chk out on this.

Kind Rgds,
Ashish

Is it possible to call and execute .exe file from an excel macro? If yes how can I do it.

Thanks

i've a problem.

I have to distribute an excel file containing an hyperlink to a
external program that is supposed to be in users' PC.

the problem is i don't know where this file is saved inside other users
HD then i can't create a universal hyperlink to open it directly from
the excel file.

this external program have its own installation folder and its .exe
icon but, i can not know in which disk is located.

so how can i create a universal hyperlink able to open this .exe file
from its real path???

thx !

dear All,

I have an .exe file that I need to run from inside a macro. Is it possible? The .exe file also takes command line arguments.

Thanks

hi All,
I have a nice little macro that runs a .exe file.
it has an error trap in it to detect if the .exe is already active.

my problem is to get the selected .exe to be the active window and bring it to the forground for usage.

Cheers in advance.
Alan

Hi Experts,

Can someone please help me with the syntax as how to run an calc.exe files through excel macro which is in c:raj

How do I run a Batch file from within a macro?
I tried the Shell command but it dos'nt run the file.
Shell "O:Services Logisticsgeneralinv_planPART's LIBRARYList.bat

Thanx in advance

hi friends,

Is there any way to create exe file for macro code?

I am using a vb form to create an interface for importing and charting data from external files.
While running the form from the vb editor everything works fine.
To make my form appear for the users of my spreadsheet I placed Form.show in the Workbook_Open subroutine. When launching my form this way I get Runtime error 52 "Bad file name or number". Usung the debugger I checked the file name and it was correct, I also changed my code to use FreeFile to select the file number for me.
Any help would be greatly appreciated.

Good day everybody,

I am using Excel 2002 and would like to create a worksheet report with a
button.
When user click the button, it will run a EXE file that will process and
update the database. The button will also refresh the database query in the
Excel worksheet.
Can anyone guide me how to write the code for the button?

Thanks in advance and have a nice day.

Best regards,
Julie

Hi, can Anyone tell me how to get the

[I]'Run this file from its current location or Save this file to disk'

box to load. Basically im trying to load a excel spreadsheet from frontpage. Everytime I load the file, it loads in Internet Explorer. I don't want it to do that. I want it to load as a separate excel file (in excel itself). Any ideas...

I've got a ssis package. I need to get it to call an external .exe
file, and pass that file one or two parameters. The external file was
written in vb.net, if that makes any difference at all.

I've looked for the "execute" command, and not finding much. "Call",
not finding much. "Shell", not finding much.

Any help?

I can start an exe file in excel using vb code "fileOpen=shell("file
name",vbMaximizeFocus)

Hi,
I have an .exe file in a certain folder.
How can I run it from a VBA macro?

Hi, I have the following question:

How can I run a DOS .bat (batch) file from within a Macro?

This is what I came up with so far and it seems to work. The only thing is that I need this to have relative paths, running from the same directory the Excel Workbook is in.

With absolute paths, this is what I have

The thing is I would need to run the web_hotel_check.bat file using a relative path...

Any ideas?
Thanks to all of your for your time.

Titus

As part of a larger script this is the only part that I cannot get to work. Your assistance would be much appreciated:-


	VB:
	
 Batch_Run() 
    Dim RetVal 
    RetVal = Shell("C:Usersuser1Documentsdfs_update.bat", 1) 
End Sub 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
The result :-

dfscmd_error.JPG

When I attempt to run this bat file from a command line the dfscmd.exe executes correctly:-

dfscmd_from_command_line.jpg

The system error shown in the last img confirms that the script works from the command line. So effectively if I can get it to respond like this when initiated from excel vb it would be perfect.

The .bat file would contain multiple command lines that would utilise Microsofts distributed file system to map/unmap dfs links to storage locations. If I can only get the .bat file executed from the excel sheet that would be great.

Your asisstance/guidance would really be much appreciated.

Regards
Ronnie

Hi,

I am trying to execute a batch file from Excel macro using the below commands...
stArgs = "C:datasheetsftp1.bat"
retval = Shell(stArgs)

ftp1.bat has the following content
@echo off
ftp -n -v -s:c:datasheetsftpinput.txt
pause

(I have added the pause command to debug the problem)
Now when I run the macro, command prompt is opening up, but showing me the message , "error cannot open ftpinput.txt."

If I double click on the ftp1.bat outside the macro , it is working fine.

How to open the txt file from Excel Macro?

Please help me

Thanks.

Is it possible to run a *bat file from a macro ?? if yes how??

For example the bat file name is test01.bat

How can I run this bat file from this sub

Sub mysub01()

Dim FieldOrderChk As String
FieldOrderChk = "=IF(ISERROR(VLOOKUP(R[-1]C,[Fields.xls]PDiff_Fields!R5C1:R50C2,2,FALSE)),"""",VLOOKUP(R[-1]C,[Fields.xls]PDiff_Fields!R5C1:R50C2,2,FALSE))"

If Range("A2").FormulaR1C1 = FieldOrderChk Then
ActiveWorkbook.Save
ActiveWindow.Close
Else
Application.Run "SuppInf.xls!DPDF_Field_Order"
Application.Run "SuppInf.xls!DPDF_Cntrz_End_Chk_Formula1"
End If
ActiveWorkbook.Save
ActiveWindow.Close

!!! Here run / exec test01.bat

End Sub

Thank you

Hi,

I am using the Print command to write a DOS .bat file from Excel and then executing it with AppActivate.

Problem is it is actually working fine. Moving a file and renaming it to another directory.

It just crashes the macro every time though...

I can replace the "C:Sounding.bat" file with any executable .exe and it wont crash but if i run CMD or any bat file it will...

Dim MovWAV
MovWAV = Shell("C:Sounding.bat", 0)
AppActivate MovWAV

Any one to help what i am doing wrong?

Thanks in advance.

Barrett.

I'm not exactly a newbie at excel macros but not an expert....

I was wondering if there is a way to open up a given program (notepad in my example) ..paste data from cells copied in excel and save the notepad file to a specific location and close it out??
The file path will be given from a data cell in excel as well as the file name.

From searching the forums i've come up with the way to open notepad
using the lines

Dim RetVal As Variant
RetVal = Shell("C:WINDOWSSYSTEM32notepad.exe")

any help would be very much appriciated!!! Thanks

I've been working a lot with VBA lately and finally got all my macros working just as I need them to. Even designed a form that has buttons to all the Sub's i use.

I just wanted to know if there is a way to convert my VBA to an executable *.exe file so that i can run all the sub's i've created from the userform i created.

Anybody care to point me in the right direction for this?

Hi

Someone has written me a simple vbs script which uploads files to an ftp site. What I would like to do is to run the script from within an Excel macro - ideally immediately after the macro creates the files which are going to be uploaded. Can it be done? I know a bit about macros, but virtually nothing about vbs.

Cheers
free

Hi,
I realy need to pass aruments to macro(Auto_Open)s of excel file from
command prompt.
I tried with following code
-----------------------------------------------------------------------------
Declare Function GetCommandLine Lib "kernel32" _
Alias "GetCommandLineA" () As Long
Declare Function lstrlen Lib "kernel32" _
Alias "lstrlenA" (ByVal lpString As Long) As Long
Declare Function lstrcpy Lib "kernel32" _
Alias "lstrcpyA" (ByVal lpDestString As String, )
ByVal lpSrcString As Long) As Long

Sub Test()
MsgBox CommandLine()
End Sub

Function CommandLine() As String
Dim Ptr As Long, Length As Long, VBString As String

Ptr = GetCommandLine() 'pointer to the buffer
Length = lstrlen(Ptr) 'length of null-terminated string
VBString = Space$(Length) 'allocate buffer
lstrcpy VBString, Ptr 'copy the string: note the order of the
args!
CommandLine = VBString
End Function
------------------------------------------------------------------------------
I used command line as
>start excel c:myfoldermyexcel.xls /e/123/hello/abc
but it's ignoring arguments at the end of command line(after space)
I did n't get why that getCommandLine function is not taking full
arguments.

it's taking till "excel.exe c:myfoldermyexcel.xls" and ignoring
agruments after taht.
I have doubt am i using correct switch(/e for arguments).
So please let me know what's problem that.

pls help me in soving this problem

regards
poli

Hi All,

Does anyone know if it is possible (and if so how?) to run a .exe file from VBA in excel? Specifically, I would like to add a command button to my worksheet and when it is pressed it runs a .exe file which is in the same folder as the excel workbook. The .exe file will not be used in any way by excel; it will only display information for the user.

Any help would be appreciated.

Best Regards,

Aaron


No luck finding an answer? You could always try Google.