How to loop through excel cells using DDERequest?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
ctc531
Newbie
Posts: 2
Joined: Mon May 22, 2006 4:11 pm

How to loop through excel cells using DDERequest?

Post by ctc531 » Mon May 22, 2006 4:17 pm

Hi.

I am experimenting with the command
DDERequest>Excel,c:\myfile.xls,R1C1,60

I want to loop through several cells
R1C1,R2C1,R3C1......etc

I tried using ConCat, but it does not seem to work with strings and numbers.

Any Ideas? How can I generate the series above?

Thanks

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon May 22, 2006 4:19 pm

Have a look at the Read From Excel sample script that comes with Macro Scheduler:

Code: Select all

//Specify the path of the Excel file here
Let>filename=%SCRIPT_DIR%\example.xls

IfFileExists>filename

   //Start Excel
   ExecuteFile>filename
   WaitWindowOpen>Microsoft Excel -*

   //Ask how many rows we should get
   Input>maxrows,How many rows shall I get?,200

   //As an example I'm going to paste the data into Notepad
   Run>Notepad.exe
   WaitWindowOpen>Untitled - Notepad

   Let>r=2
   Repeat>r
      //get the fields for this row
      DDERequest>Excel,filename,R%r%C1,field_1,60
      DDERequest>Excel,filename,R%r%C2,field_2,60
      DDERequest>Excel,filename,R%r%C3,field_3,60
      DDERequest>Excel,filename,R%r%C4,field_4,60

      //remove the CRLF that Excel adds
      StringReplace>field_1,CRLF,,field_1
      StringReplace>field_2,CRLF,,field_2
      StringReplace>field_3,CRLF,,field_3
      StringReplace>field_4,CRLF,,field_4

      //For this example we'll just paste each row into Notepad
      SetFocus>Notepad*
      Send>Row: %r%
      Press Tab
      Send>%field_1%
      Press Tab
      Send>%field_2%
      Press Tab
      Send>%field_3%
      Press Tab
      Send>%field_4%
      Press Enter
      //you'll want to replace the above lines to send the data to your real app.

      Let>r=r+1
   Until>r=maxrows

Else
  MessageModal>Could not find: %filename%
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

ctc531
Newbie
Posts: 2
Joined: Mon May 22, 2006 4:11 pm

Fastest Reply Ever!

Post by ctc531 » Mon May 22, 2006 4:22 pm

Thanks

I wat to take a look at it.

I never expected such a super quick reply!

Great Support guys!!!!!

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