Store Data as a Variable

Share your macros, knowledge, solutions, services, ...
Post Reply
Posts: 2
Joined: Tue Mar 21, 2017 12:24 pm

Store Data as a Variable

Post by DavidCB » Tue Mar 21, 2017 12:46 pm

Store Data as a Variable the paste individually

So, I am a little stuck.

I have a spread sheet containing a database - fields across the top, Excel.

Need to move the data, in individual cells, to another application, but it’s a non-windows app.

I was able to use the recorder and get it done, moving each individual fields one at a time, this got kind of cumbersome with switching back and forth from active windows, although it works.

What I was thinking was storing each field in a record in the database to a separate variable, var1, var2..…var 12…all at the same time, hence keeping the active window issue at a minimum.

Then switching over too the other application, and selecting the 1st field, then pasting the corresponding variable (var1) , going to the second field, and paste the corresponding variable (var2)..And continuing down the line.

Then repeating the process with a loop.

I’ve looked at the forum topic using the “vCsvFile” command and kind of got my head raped around it, it has to be kind of the same principle.
I guess what I’m asking is , what commands I should be looking at,

Something like , get data, store to variable, then past variable commands.

Even better, am I on the right track…..


Posts: 106
Joined: Tue Oct 18, 2016 1:12 pm

Re: Store Data as a Variable

Post by Petr » Thu Apr 13, 2017 3:54 pm

The example that you can download below shows how to open Excel file, read data from spreadsheet cells and then insert data to other application (text editor in this sample).
Just download the zip file, unzip all files to a folder and open CopyPasteExcelData.4tw file in Macro Toolworks Professional. There is just one macro to run (see it below). Note: You must have Excel installed. ...

Code: Select all

<#>Open Excel file and read data
<excel_wb_close>(%vWorkbook%,0)<#>Open text file where to put the data
<if_win>("[*PasteDataTo.txt*|#Notepad|#305|#49]","ACT",0)<#>If opened and receiving keyboard input then insert the data.
<#>Go to the end of the file first
<msg>(-100,-100,"File where to insert data cannot be open.","Error",1,0,2,0)<#>

Post Reply