Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Run an external bat file from inside VBA

I am trying to create a Metrics report in Excel 7. The data for the report is
in an MKS application History. MKS does not provide a way to collect the
history data other than using a command line interface.
I have manually typed in the command line and run it redirecting the result
to a text file. I have written a macro tha loads the text file into excel and
parses the data for the information I need.
I have to create the report weekly and would like to be able to run the
command line from the macro.
My approach is to create the command line in the macro, save as a text file
with the .bat extension, run the bat file and then load the result and parse
it for the data I need.
The piece I do not know how to do is execute the external file from the macro.

If there is a way to run a command line inside Excel that would work as well.

Thanks for any help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Run an external bat file from inside VBA

Hi -

Try the shell() function, which I use sometimes like the following.

Sub run_proc()
on error resume next

dim rc, out_file
out_file = "c:\windows\temp\pgm.out"

rc = Shell("perl -S GetFileList.pl " & out_file, vbNormalFocus)
if err then msgbox error$
if rc <= 0 then msgbox "other err"

' may want to chk w others on using the following
DoEvents( )

End Sub



"RockyMountainHiker" wrote:

I am trying to create a Metrics report in Excel 7. The data for the report is
in an MKS application History. MKS does not provide a way to collect the
history data other than using a command line interface.
I have manually typed in the command line and run it redirecting the result
to a text file. I have written a macro tha loads the text file into excel and
parses the data for the information I need.
I have to create the report weekly and would like to be able to run the
command line from the macro.
My approach is to create the command line in the macro, save as a text file
with the .bat extension, run the bat file and then load the result and parse
it for the data I need.
The piece I do not know how to do is execute the external file from the macro.

If there is a way to run a command line inside Excel that would work as well.

Thanks for any help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Run an external bat file from inside VBA

Hi

Thanks, I modified it to run the command line directly after passing it the
CLI string and the Output file.
It works great

Sub run_proc(CLI As String, outFile As String)
On Error Resume Next

Dim rc As Variant

rc = Shell("cmd.exe /C" & CLI & " " & outFile, vbHide)
If Err Then MsgBox Error$
If rc <= 0 Then MsgBox "other err"

End Sub

"MeistersingerVonNurnberg" wrote:

Hi -

Try the shell() function, which I use sometimes like the following.

Sub run_proc()
on error resume next

dim rc, out_file
out_file = "c:\windows\temp\pgm.out"

rc = Shell("perl -S GetFileList.pl " & out_file, vbNormalFocus)
if err then msgbox error$
if rc <= 0 then msgbox "other err"

' may want to chk w others on using the following
DoEvents( )

End Sub



"RockyMountainHiker" wrote:

I am trying to create a Metrics report in Excel 7. The data for the report is
in an MKS application History. MKS does not provide a way to collect the
history data other than using a command line interface.
I have manually typed in the command line and run it redirecting the result
to a text file. I have written a macro tha loads the text file into excel and
parses the data for the information I need.
I have to create the report weekly and would like to be able to run the
command line from the macro.
My approach is to create the command line in the macro, save as a text file
with the .bat extension, run the bat file and then load the result and parse
it for the data I need.
The piece I do not know how to do is execute the external file from the macro.

If there is a way to run a command line inside Excel that would work as well.

Thanks for any help.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MACRO inside PROTECTED FILE - Please help ivo Excel Discussion (Misc queries) 9 January 5th 08 07:47 PM
Display external data inside of an Excel 2007 Spread sheet jingles457 Excel Worksheet Functions 2 November 15th 07 04:36 PM
get file name inside a macro on Excel Get a file name inside a macro Excel Worksheet Functions 2 October 17th 06 10:33 PM
REcover dropped Data when still inside the file excUser Excel Discussion (Misc queries) 0 March 21st 06 01:56 PM
Execute a batch file from inside Excel Eric[_14_] Excel Programming 2 November 12th 03 05:21 PM


All times are GMT +1. The time now is 12:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"