Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem with SendKeys + active window

Hi,

I want to get data from another application (SAP). I'm using VBA i
Excel to control SAP using the command SendKeys. My goal is to launc
SAP, log in, perform some actions and save the results in a dat.file.
have already completed the code for doing so and it works just fine.

However, my problem is that if, while running the macro, anothe
application (for example my ergonomic program, the company messenge
service or the screensaver) pops up, the macro sends the keys to th
wrong application.

Is there any way I can prevent such a situation? Or when it's no
possible to prevent, at least detect that it's gone wrong? Or is i
possible to activate the SAP window before every time Excel sends keys
Or does anyone have a better solution?

TIA,

Anne

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Problem with SendKeys + active window

Hi Roadie

That's why I avoid SendKeys
Try to add this for every SendKeys line
Don't know if this work but you can try

AppActivate Application.Caption



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Roadie " wrote in message ...
Hi,

I want to get data from another application (SAP). I'm using VBA in
Excel to control SAP using the command SendKeys. My goal is to launch
SAP, log in, perform some actions and save the results in a dat.file. I
have already completed the code for doing so and it works just fine.

However, my problem is that if, while running the macro, another
application (for example my ergonomic program, the company messenger
service or the screensaver) pops up, the macro sends the keys to the
wrong application.

Is there any way I can prevent such a situation? Or when it's not
possible to prevent, at least detect that it's gone wrong? Or is it
possible to activate the SAP window before every time Excel sends keys?
Or does anyone have a better solution?

TIA,

Annet


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Problem with SendKeys + active window

Hi Annet,

Is there any way I can prevent such a situation? Or when it's not
possible to prevent, at least detect that it's gone wrong? Or is it
possible to activate the SAP window before every time Excel sends
keys? Or does anyone have a better solution?


As Ron pointed out, SendKeys can be very unreliable. I'd suggest
programmatically controlling SAP if possible. It would undoubtedly be more
work, but it would be a more robust solution in the long term. Here's a
page on the SAP site that suggests that automation of SAP from an external
application is possible:

http://help.sap.com/saphelp_45b/help...d/frameset.htm

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem with SendKeys + active window

Thanks for your reactions.

The AppActivate command could be an option, but I'm afraid that's stil
not fully safe.

I would like to make a macro that controls SAP and performs all th
actions, but I'm not sure how. I have done something similar wit
another application (Reflection), but that was much easier, becaus
Reflection had a recorder built in.
I can see in the menu that SAP has options like 'Report', 'Utilities'
'Jobs', so I guess SAP may have a recorder, but since I'm no
authorized to perform those transactions, that's not very helpful.
Getting authorization is probably a Mission Impossible, becaus
management believes that we should use SAP instead of Excel and the
won't support my attempts to get our IT-department to help me, althoug
I myself and my colleagues are convinced that Excel is a better too
for making Graphs etc.

I have a feeling I should use CreateObject and I think I need som
library, but I really can't find out where to find it. How can I fin
out what I need and where can I find it? Or should I use somethin
else? I have some knowledge of using ODBC, but in this case, that's no
an option. I know very little of DAO, OLE, ActiveX.
Can anyone help me? Or maybe give a hint as to what direction I shoul
go? Preferably with examples? Please???

TIA again,

Anne

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Problem with SendKeys + active window

Hi Annet,

I'm not very familiar with SAP. I would suggest you do a google search on
"Automate" and "SAP" and "vb" to get more information. I did this and found
the following site, which has some more info:

http://www.sapgenie.com/interfaces/

It looks like there are quite a few third-party solutions that may work for
you. You may also want to post to an SAP newsgroup if you can find one....

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Thanks for your reactions.

The AppActivate command could be an option, but I'm afraid that's
still not fully safe.

I would like to make a macro that controls SAP and performs all the
actions, but I'm not sure how. I have done something similar with
another application (Reflection), but that was much easier, because
Reflection had a recorder built in.
I can see in the menu that SAP has options like 'Report', 'Utilities',
'Jobs', so I guess SAP may have a recorder, but since I'm not
authorized to perform those transactions, that's not very helpful.
Getting authorization is probably a Mission Impossible, because
management believes that we should use SAP instead of Excel and they
won't support my attempts to get our IT-department to help me,
although I myself and my colleagues are convinced that Excel is a
better tool for making Graphs etc.

I have a feeling I should use CreateObject and I think I need some
library, but I really can't find out where to find it. How can I find
out what I need and where can I find it? Or should I use something
else? I have some knowledge of using ODBC, but in this case, that's
not an option. I know very little of DAO, OLE, ActiveX.
Can anyone help me? Or maybe give a hint as to what direction I should
go? Preferably with examples? Please???

TIA again,

Annet


---
Message posted from http://www.ExcelForum.com/


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
Active Window Question CWillis Excel Discussion (Misc queries) 4 July 19th 06 05:52 PM
SendKeys syntax problem VBAvirgin New Users to Excel 2 January 4th 06 04:42 PM
SendKeys problem Rod Armour Excel Programming 3 January 23rd 04 10:44 PM
SendKeys, Windows Active screen Question..Pls Help!!! Rumil Excel Programming 1 January 21st 04 12:56 AM
SendKeys and Path Problem rdcord Excel Programming 3 September 11th 03 06:12 PM


All times are GMT +1. The time now is 07:14 AM.

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"