get variable - please help

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
hr.brenner
Newbie
Posts: 3
Joined: Tue Oct 21, 2003 12:18 pm
Location: Austria

get variable - please help

Post by hr.brenner » Tue Oct 21, 2003 12:27 pm

what i want to do is: to get from a program (Microsoft Excel e.g.) a value which should be handled as an variable. this variable i want to import into the macro for the mouse command.
i am an absolut beginner, looked in the helpfile, but don´t know any futher.

to get this variable should happen in macro totally automatic (no manual input) .... but how??? i tried it with copy/paste - as you can see ... ???

here is what i programmed so far, but i have a problem with the "input command".

SetFocus>Microsoft Excel*
Wait>2
MouseMoveRel>296,154
LDblClick
LDblClick
Press CTRL
Send Character/Text>c
Release CTRL
Wait>2
Input>name,variable from Excel
Wait>1
Press CTRL
Send Character/Text>v
Release CTRL
Wait>1
Press Enter
MouseMoveRel>%name%,425

what is wrong?? please help me with this.
thank you very much

hr.brenner

Lumumba

Post by Lumumba » Tue Oct 21, 2003 4:45 pm

SetFocus>Microsoft Excel*
Wait>2
MouseMoveRel>296,154
LDblClick

//What's that second DblClick for ?
LDblClick

//Here you copy a value to the clipboard
Press CTRL
Send Character/Text>c
Release CTRL

//Wait>2
//Input>name,variable from Excel
//Wait>1
//Press CTRL
//Send Character/Text>v
//Release CTRL
//Wait>1
//Press Enter

//Take the current value from the clipboard and assign it to the variable "Xpos"
GetClipboard>Xpos

MouseMoveRel>%Xpos%,425

Have a look at the more advanced command: DDERequest>
Sample script snippet should be available at the scripts download area.

Guest

Post by Guest » Wed Oct 22, 2003 11:18 am

@Lumumba thank you very much, the GetClipboard>Xpos command worked fine.

it is probably really better to use the more advanced command: DDERequest>
but i have a problem with it. i used the seach function in this forum and read all the posts.

this is what i did first.

SetFocus>Microsoft Excel*
DDERequest>Excel,C:\Download\test.xls,R1C1,ret,10
Message>%ret%

result: the excel window gets active and opens. no message window pops up and the macro does not respond anymore.
(if i type SetFocus>Excel* as in the examples from others, the window does not open. i have to type SetFocus>Microsoft Excel*)


2nd try:
SetFocus>Microsoft Excel*
DDERequest>Microsoft Excel*,C:\Download\test.xls,R1C1,ret,10
Message>%ret%

result: message: DDE_SERVICE_INVALID
also same result with
DDERequest>Microsoft Excel,C:\Download\test.xls,R1C1,ret,10

3rd try:
SetFocus>Microsoft Excel*
DDERequest>Excel,C:\Download\test.xls,L1C1,ret,10
Message>%ret%

line instead of row (french version) ... no success
actually i have the german version of excel, use Win2000 and Excel 2000

can you or somebody else help me again???

thank you very much

hr.brenner

Guest

Post by Guest » Wed Oct 22, 2003 3:00 pm

Ich denke das Problem liegt in der Reihenfolge/im Timing:

1. die Arbeitsmappe muß aktiv sein
2. warten bis Fenster aktiv ist
3. Focus setzen (sicher ist sicher :o)
4) Info aus Zelle auslesen
5) Info anzeigen/weiter verarbeiten

ExecuteFile>C:\Download\test.xls
WaitWindowOpen>Microsoft Excel - test.xls
SetFocus>Microsoft Excel - test.xls
DDERequest>Excel,C:\Download\test.xls,R1C1,ret,10
Message>%ret%

hr.brenner
Newbie
Posts: 3
Joined: Tue Oct 21, 2003 12:18 pm
Location: Austria

Post by hr.brenner » Mon Oct 27, 2003 2:42 pm

hi,

i still don´t know why i doesn´t work.
i tried this:
ExecuteFile>C:\Download\test.xls
WaitWindowOpen>Microsoft Excel - test.xls
SetFocus>Microsoft Excel - test.xls
DDERequest>Excel,C:\Download\test.xls,R1C1,ret,10
Message>%ret%

?????????

hr.brenner

Guest

Post by Guest » Tue Oct 28, 2003 4:22 pm

Läuft Bestens!

Hast Du den Code direkt aus dem Forum in ein Script kopiert? Damit hätte dann jede Zeile Code ein (ungewolltes/unsichtbares) Leerzeichen am Ende. Was zu Problemen während der Ausführung eines Scripts führen kann. Bitte deshalb nach Copy&Paste grundsätzlich prüfen!

-----

//File will be opened within Excel
ExecuteFile>C:\Download\test.xls

//Wait till window is available
WaitWindowOpen>Microsoft Excel - test.xls

//Set focus to that specific file (better, if lost for whatever reason)
SetFocus>Microsoft Excel - test.xls

//Cell content will be requested with DDE (DynamicDataExchange) from row1/cell1 and set in variable "ret". Excel/file has to be open/active during that request.
DDERequest>Excel,C:\Download\test.xls,R1C1,ret,10
Message>%ret%

hr.brenner
Newbie
Posts: 3
Joined: Tue Oct 21, 2003 12:18 pm
Location: Austria

Post by hr.brenner » Thu Oct 30, 2003 8:35 am

hallo,

danke für deine bemühungen, aber ich kriegs nicht hin.
ich hab die leerzeichen nochmal weggelöscht, gespeichert..
und erhalte immer das ergebnis: DDE_TIMED_OUT

ich kann mir nicht vorstellen woran das liegt.
ich möchte dich bitten ob du mir das script per mail schicken könntest (*.scp) ???

an [email protected]

vielen dank
hr.brenner

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts