Excel variable use in macro

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
AMIPIERRE
Newbie
Posts: 2
Joined: Sun Aug 10, 2014 4:13 am

Excel variable use in macro

Post by AMIPIERRE » Sun Aug 10, 2014 4:20 am

Hi
My original question was: In a Web page where I cannot paste a value from Excel, how can I make a choice in that rectangle from a cell.value?

Thank.
Last edited by AMIPIERRE on Mon Aug 18, 2014 8:49 pm, edited 1 time in total.

hagchr
Automation Wizard
Posts: 331
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: Excel variable use in macro

Post by hagchr » Sun Aug 10, 2014 12:08 pm

Hi, just before saving I note the original question has been removed, however, here is what I would have suggested. Hopefully it still helps. Depending on the web site and what you want to do you may want to check MS tools to interact with web pages if there is a better way.

//Your excel sheet (check extension)
Let>tmp=C:\...\Classeur1.xlsx

//Open the excel file and read cell A1 in sheet feuil1 into the variable strCell
XLOpen>tmp,1,xlBook
XLGetCell>xlBook,feuil1,1,1,strCell

//Look for a number in strCell. NM gives number of numbers found, M_1 gives first one found etc
// \d+ is RegEx language meaning one or more digits, ie a number in this case.
RegEx>\d+,strCell,0,M,NM,0

If>NM>0
//You need to change this part
//and set focus on the web page
//you are working with etc.

MessageModal>Number is: %M_1%
SetFocus>Microsoft Excel*
Wait>1
Press>Down *%M_1%
Else
MessageModal>No Number found
Endif

  View Snippet Page

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

Re: Excel variable use in macro

Post by Marcus Tettmar » Tue Aug 12, 2014 3:17 pm

Please don't remove questions. It removes any sense from the thread. Now we have a thread with an answer but no question. One of the main benefits and purposes of a forum is to help EVERYONE - not just the original posted. With the original question intact, other people's responses make sense and the thread may be useful to others. Even if you've already found the answer, it still pays to leave the original post. By all means reply to your own post with the solution. That will also help people.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

AMIPIERRE
Newbie
Posts: 2
Joined: Sun Aug 10, 2014 4:13 am

Re: Excel variable use in macro

Post by AMIPIERRE » Mon Aug 18, 2014 9:03 pm

Thanks hagchr. It's another way that gives me good lesson.

The way I solved, for the beginner I am, is like this:

In the webpage, there's that place where I have to chose between five entries. In my Excel Workbook, I use those names and I associated the right number of click down to each name. That number becomes a variable in MS.

// ROLE

SetFocus>Microsoft Excel (Name of the Workbook)
wait>0.5
'Name the value from cell A5 in SHEET1
XLGetCell>XLBook,sheet1,1,5,ROLEnb
wait>0.5
'Return to the Webpage where, using the keyboard, I stand at the right rectangle
SetFocus>Webpage - Internet Explorer
wait>0.5
press down * %ROLEnb%
press Enter

Apologies Marcus

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