Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default API run program

i am new to programming.
I want to run a program and if it gives an error the OK button should be
pressed automaticly

Any help to this???

I know that I must use API but how to I activate API in excel?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,344
Default API run program

Hi,

Please give us more info on what you are doing, like the code. For one
thing, you don't need to call an API to click an OK button. You should just
build in an error trap, an error handler to deal with the error, and that can
all be done in Excel.


--
Thanks,
Shane Devenshire


"Johan" wrote:

i am new to programming.
I want to run a program and if it gives an error the OK button should be
pressed automaticly

Any help to this???

I know that I must use API but how to I activate API in excel?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default API run program

Something like this is my code:

Dim Shell
Set Shell = CreateObject("WScript.Shell")
Shell.Run "c:\battest\vbimport", 1
SendKeys "{enter}"

The file vbimport gives an error, and I want to send the key Enter to the
message box.

Thanks
ShaneDevenshire skrev:

Hi,

Please give us more info on what you are doing, like the code. For one
thing, you don't need to call an API to click an OK button. You should just
build in an error trap, an error handler to deal with the error, and that can
all be done in Excel.


--
Thanks,
Shane Devenshire


"Johan" wrote:

i am new to programming.
I want to run a program and if it gives an error the OK button should be
pressed automaticly

Any help to this???

I know that I must use API but how to I activate API in excel?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,805
Default API run program

Try
SendKeys "~", True
instead of SendKeys "{enter}"
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Johan" wrote:

Something like this is my code:

Dim Shell
Set Shell = CreateObject("WScript.Shell")
Shell.Run "c:\battest\vbimport", 1
SendKeys "{enter}"

The file vbimport gives an error, and I want to send the key Enter to the
message box.

Thanks
ShaneDevenshire skrev:

Hi,

Please give us more info on what you are doing, like the code. For one
thing, you don't need to call an API to click an OK button. You should just
build in an error trap, an error handler to deal with the error, and that can
all be done in Excel.


--
Thanks,
Shane Devenshire


"Johan" wrote:

i am new to programming.
I want to run a program and if it gives an error the OK button should be
pressed automaticly

Any help to this???

I know that I must use API but how to I activate API in excel?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default API run program

What type of file is vbimport? Does it have a file extension (you may not
see the file extension if Windows Explorer is set to hide extensions of
known file types but the extension may be important here)? Is vbimport a
batch file or a vbScript file or something else?

Steve Yandl

"Johan" wrote in message
...
Something like this is my code:

Dim Shell
Set Shell = CreateObject("WScript.Shell")
Shell.Run "c:\battest\vbimport", 1
SendKeys "{enter}"

The file vbimport gives an error, and I want to send the key Enter to the
message box.

Thanks
ShaneDevenshire skrev:

Hi,

Please give us more info on what you are doing, like the code. For one
thing, you don't need to call an API to click an OK button. You should
just
build in an error trap, an error handler to deal with the error, and that
can
all be done in Excel.


--
Thanks,
Shane Devenshire


"Johan" wrote:

i am new to programming.
I want to run a program and if it gives an error the OK button should
be
pressed automaticly

Any help to this???

I know that I must use API but how to I activate API in excel?





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default API run program

vbimport is a chortcut to a program.

Steve Yandl skrev:

What type of file is vbimport? Does it have a file extension (you may not
see the file extension if Windows Explorer is set to hide extensions of
known file types but the extension may be important here)? Is vbimport a
batch file or a vbScript file or something else?

Steve Yandl

"Johan" wrote in message
...
Something like this is my code:

Dim Shell
Set Shell = CreateObject("WScript.Shell")
Shell.Run "c:\battest\vbimport", 1
SendKeys "{enter}"

The file vbimport gives an error, and I want to send the key Enter to the
message box.

Thanks
ShaneDevenshire skrev:

Hi,

Please give us more info on what you are doing, like the code. For one
thing, you don't need to call an API to click an OK button. You should
just
build in an error trap, an error handler to deal with the error, and that
can
all be done in Excel.


--
Thanks,
Shane Devenshire


"Johan" wrote:

i am new to programming.
I want to run a program and if it gives an error the OK button should
be
pressed automaticly

Any help to this???

I know that I must use API but how to I activate API in excel?




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,805
Default API run program

Did you try SendKeys "~", True?
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Johan" wrote:

vbimport is a chortcut to a program.

Steve Yandl skrev:

What type of file is vbimport? Does it have a file extension (you may not
see the file extension if Windows Explorer is set to hide extensions of
known file types but the extension may be important here)? Is vbimport a
batch file or a vbScript file or something else?

Steve Yandl

"Johan" wrote in message
...
Something like this is my code:

Dim Shell
Set Shell = CreateObject("WScript.Shell")
Shell.Run "c:\battest\vbimport", 1
SendKeys "{enter}"

The file vbimport gives an error, and I want to send the key Enter to the
message box.

Thanks
ShaneDevenshire skrev:

Hi,

Please give us more info on what you are doing, like the code. For one
thing, you don't need to call an API to click an OK button. You should
just
build in an error trap, an error handler to deal with the error, and that
can
all be done in Excel.


--
Thanks,
Shane Devenshire


"Johan" wrote:

i am new to programming.
I want to run a program and if it gives an error the OK button should
be
pressed automaticly

Any help to this???

I know that I must use API but how to I activate API in excel?




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default API run program

The problem is that the code moves on before I got the error code, How do I
get the code to wait

Sheeloo skrev:

Did you try SendKeys "~", True?
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Johan" wrote:

vbimport is a chortcut to a program.

Steve Yandl skrev:

What type of file is vbimport? Does it have a file extension (you may not
see the file extension if Windows Explorer is set to hide extensions of
known file types but the extension may be important here)? Is vbimport a
batch file or a vbScript file or something else?

Steve Yandl

"Johan" wrote in message
...
Something like this is my code:

Dim Shell
Set Shell = CreateObject("WScript.Shell")
Shell.Run "c:\battest\vbimport", 1
SendKeys "{enter}"

The file vbimport gives an error, and I want to send the key Enter to the
message box.

Thanks
ShaneDevenshire skrev:

Hi,

Please give us more info on what you are doing, like the code. For one
thing, you don't need to call an API to click an OK button. You should
just
build in an error trap, an error handler to deal with the error, and that
can
all be done in Excel.


--
Thanks,
Shane Devenshire


"Johan" wrote:

i am new to programming.
I want to run a program and if it gives an error the OK button should
be
pressed automaticly

Any help to this???

I know that I must use API but how to I activate API in excel?



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,805
Default API run program

Here is the complete code
Sub testSendKeys()
Dim ReturnValue
ReturnValue = Shell(c:\battest\vbimport,1)
AppActivate ReturnValue
SendKeys "~" , TRUE
End Sub


--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Johan" wrote:

The problem is that the code moves on before I got the error code, How do I
get the code to wait

Sheeloo skrev:

Did you try SendKeys "~", True?
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Johan" wrote:

vbimport is a chortcut to a program.

Steve Yandl skrev:

What type of file is vbimport? Does it have a file extension (you may not
see the file extension if Windows Explorer is set to hide extensions of
known file types but the extension may be important here)? Is vbimport a
batch file or a vbScript file or something else?

Steve Yandl

"Johan" wrote in message
...
Something like this is my code:

Dim Shell
Set Shell = CreateObject("WScript.Shell")
Shell.Run "c:\battest\vbimport", 1
SendKeys "{enter}"

The file vbimport gives an error, and I want to send the key Enter to the
message box.

Thanks
ShaneDevenshire skrev:

Hi,

Please give us more info on what you are doing, like the code. For one
thing, you don't need to call an API to click an OK button. You should
just
build in an error trap, an error handler to deal with the error, and that
can
all be done in Excel.


--
Thanks,
Shane Devenshire


"Johan" wrote:

i am new to programming.
I want to run a program and if it gives an error the OK button should
be
pressed automaticly

Any help to this???

I know that I must use API but how to I activate API in excel?



  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default API run program

Thanks but now I got an error on this line:
ReturnValue = Shell("c:\battest\vbimport", 1)

saying:
Object does not support this property or metode

Hope you can help the beginner!!!

Thanks
Johan
Sheeloo skrev:

Here is the complete code
Sub testSendKeys()
Dim ReturnValue
ReturnValue = Shell(c:\battest\vbimport,1)
AppActivate ReturnValue
SendKeys "~" , TRUE
End Sub


--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Johan" wrote:

The problem is that the code moves on before I got the error code, How do I
get the code to wait

Sheeloo skrev:

Did you try SendKeys "~", True?
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Johan" wrote:

vbimport is a chortcut to a program.

Steve Yandl skrev:

What type of file is vbimport? Does it have a file extension (you may not
see the file extension if Windows Explorer is set to hide extensions of
known file types but the extension may be important here)? Is vbimport a
batch file or a vbScript file or something else?

Steve Yandl

"Johan" wrote in message
...
Something like this is my code:

Dim Shell
Set Shell = CreateObject("WScript.Shell")
Shell.Run "c:\battest\vbimport", 1
SendKeys "{enter}"

The file vbimport gives an error, and I want to send the key Enter to the
message box.

Thanks
ShaneDevenshire skrev:

Hi,

Please give us more info on what you are doing, like the code. For one
thing, you don't need to call an API to click an OK button. You should
just
build in an error trap, an error handler to deal with the error, and that
can
all be done in Excel.


--
Thanks,
Shane Devenshire


"Johan" wrote:

i am new to programming.
I want to run a program and if it gives an error the OK button should
be
pressed automaticly

Any help to this???

I know that I must use API but how to I activate API in excel?





  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default API run program

I manage to create focus to the program, but when I send the key nothing is
happening.

Any help?

Johan

Johan skrev:

Thanks but now I got an error on this line:
ReturnValue = Shell("c:\battest\vbimport", 1)

saying:
Object does not support this property or metode

Hope you can help the beginner!!!

Thanks
Johan
Sheeloo skrev:

Here is the complete code
Sub testSendKeys()
Dim ReturnValue
ReturnValue = Shell(c:\battest\vbimport,1)
AppActivate ReturnValue
SendKeys "~" , TRUE
End Sub


--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Johan" wrote:

The problem is that the code moves on before I got the error code, How do I
get the code to wait

Sheeloo skrev:

Did you try SendKeys "~", True?
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Johan" wrote:

vbimport is a chortcut to a program.

Steve Yandl skrev:

What type of file is vbimport? Does it have a file extension (you may not
see the file extension if Windows Explorer is set to hide extensions of
known file types but the extension may be important here)? Is vbimport a
batch file or a vbScript file or something else?

Steve Yandl

"Johan" wrote in message
...
Something like this is my code:

Dim Shell
Set Shell = CreateObject("WScript.Shell")
Shell.Run "c:\battest\vbimport", 1
SendKeys "{enter}"

The file vbimport gives an error, and I want to send the key Enter to the
message box.

Thanks
ShaneDevenshire skrev:

Hi,

Please give us more info on what you are doing, like the code. For one
thing, you don't need to call an API to click an OK button. You should
just
build in an error trap, an error handler to deal with the error, and that
can
all be done in Excel.


--
Thanks,
Shane Devenshire


"Johan" wrote:

i am new to programming.
I want to run a program and if it gives an error the OK button should
be
pressed automaticly

Any help to this???

I know that I must use API but how to I activate API in excel?



  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,805
Default API run program

I started with the following example given in Help
=============
Sub test1()
Dim ReturnValue, I
ReturnValue = Shell("notepad.EXE", 1)
AppActivate ReturnValue
For I = 1 To 60
SendKeys I, True
Next I
SendKeys "~", True
For I = 1 To 30
SendKeys I, True
Next I
SendKeys "%{F4}", True
SendKeys "~", True
End Sub
=============
Suggest you test with Notepad and play around
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Johan" wrote:

I manage to create focus to the program, but when I send the key nothing is
happening.

  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default API run program

Thank you, but I can not work this out.
When I run your program it does not send anything to notepad.


Sheeloo skrev:

I started with the following example given in Help
=============
Sub test1()
Dim ReturnValue, I
ReturnValue = Shell("notepad.EXE", 1)
AppActivate ReturnValue
For I = 1 To 60
SendKeys I, True
Next I
SendKeys "~", True
For I = 1 To 30
SendKeys I, True
Next I
SendKeys "%{F4}", True
SendKeys "~", True
End Sub
=============
Suggest you test with Notepad and play around
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Johan" wrote:

I manage to create focus to the program, but when I send the key nothing is
happening.

  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,805
Default API run program

Working for me...
I have Excel 2003 and put the code in the module for my workbook...
Where are you putting this code in?
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Johan" wrote:

Thank you, but I can not work this out.
When I run your program it does not send anything to notepad.


Sheeloo skrev:

I started with the following example given in Help
=============
Sub test1()
Dim ReturnValue, I
ReturnValue = Shell("notepad.EXE", 1)
AppActivate ReturnValue
For I = 1 To 60
SendKeys I, True
Next I
SendKeys "~", True
For I = 1 To 30
SendKeys I, True
Next I
SendKeys "%{F4}", True
SendKeys "~", True
End Sub
=============
Suggest you test with Notepad and play around
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Johan" wrote:

I manage to create focus to the program, but when I send the key nothing is
happening.

  #15   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default API run program

Thank you, I did copy the sub to a Module and not ThisWorkbook

Next question, if tou can help me on this, how du I start the other program
from a shortcut. I need that because the shortcut makes an automaticaly
import to the program. It is not possible to do this by strating the
"program" (.exe file).

Sheeloo skrev:

Working for me...
I have Excel 2003 and put the code in the module for my workbook...
Where are you putting this code in?
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Johan" wrote:

Thank you, but I can not work this out.
When I run your program it does not send anything to notepad.


Sheeloo skrev:

I started with the following example given in Help
=============
Sub test1()
Dim ReturnValue, I
ReturnValue = Shell("notepad.EXE", 1)
AppActivate ReturnValue
For I = 1 To 60
SendKeys I, True
Next I
SendKeys "~", True
For I = 1 To 30
SendKeys I, True
Next I
SendKeys "%{F4}", True
SendKeys "~", True
End Sub
=============
Suggest you test with Notepad and play around
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Johan" wrote:

I manage to create focus to the program, but when I send the key nothing is
happening.



  #16   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,805
Default API run program

Go to the shortcut, right-click and choose properties.
Copy the text in the Target box.

Replace the program name with the copied text in your VBA program...

--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Johan" wrote:

Thank you, I did copy the sub to a Module and not ThisWorkbook

Next question, if tou can help me on this, how du I start the other program
from a shortcut. I need that because the shortcut makes an automaticaly
import to the program. It is not possible to do this by strating the
"program" (.exe file).

Sheeloo skrev:

Working for me...
I have Excel 2003 and put the code in the module for my workbook...
Where are you putting this code in?
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Johan" wrote:

Thank you, but I can not work this out.
When I run your program it does not send anything to notepad.


Sheeloo skrev:

I started with the following example given in Help
=============
Sub test1()
Dim ReturnValue, I
ReturnValue = Shell("notepad.EXE", 1)
AppActivate ReturnValue
For I = 1 To 60
SendKeys I, True
Next I
SendKeys "~", True
For I = 1 To 30
SendKeys I, True
Next I
SendKeys "%{F4}", True
SendKeys "~", True
End Sub
=============
Suggest you test with Notepad and play around
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Johan" wrote:

I manage to create focus to the program, but when I send the key nothing is
happening.

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
Is there a way to unload the loaded XLL file in Excel? Hi all, I amdebugging XLL link library using Visual C++. Everytime I rebuild the XLL, Ihave to close the whole Excel program and relaunch the Excel program again,and then load in the newly gene LunaMoon Excel Discussion (Misc queries) 0 July 28th 08 11:03 PM
Program juanpablo Excel Discussion (Misc queries) 0 July 2nd 08 02:12 AM
My program SM Excel Worksheet Functions 2 October 22nd 05 04:52 AM
merging excel program with tdc finance program judy Excel Programming 0 November 5th 03 08:01 PM


All times are GMT +1. The time now is 11:07 PM.

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

About Us

"It's about Microsoft Excel"