Jump to content
Macro Express Forums

Retrieving array variables from Excel


Recommended Posts

Hi again! I have been experimenting with VBA in Excel. I have succeeded in creating two columns of values ( representing mouse coordinates) which I have stored in an array variable. What is the best method of getting that variable over to ME Pro? I assume registry write is an option. Will the format of the array be compatible? Excel is very good at doing what I'm trying to achieve (relative position of pixels) but I always fear that solutions that would be obvious to an experienced programmer would be lost on me! Thanks...

Link to comment
Share on other sites

If you want to permanently store it someplace, I recommend a CSV file. Then you can do the ASCII File Process to load.

Or maybe save all the X values in one file and the Y values in another with a delimiter (EG a comma) and use the split command on macro load. Then you could have two arrays in MEP where the index matches between X and Y values. That would be fast and simple to load. 

If you would like a sample, post your Excel file so I have something to show you with. 

Link to comment
Share on other sites

I have had a go at this using my two columns of data saved as a .csv.

I am seemingly getting the correct pairs of values (giving me hope!) apart from at the very first iteration I'm getting this odd symbol ... ï»¿0

I placed a text box between Ascii file begin process and ascii file end process

%T[1]%
%T[2]%
%T[3]%
%T[4]%
%T[5]%
%T[6]%
%T[7]%
%T[8]%

On running it I'm seeing

0
1

-1
0

0
1

-1
1

They are all the correct values for the start of the series. I guess I just need to trim that first value back to a 0 assuming the garbled stuff will be the same with different .csv files?

Link to comment
Share on other sites

The odd characters in the first record are there to identify the type of encoding used in the file. To avoid this try to save the .csv file in a different format, perhaps UTF-8. The format to use may or may not be shown as UTF-8. In my (older) version of Excel there is an option to save a file with the format "csv (MS-DOS)(*.csv)".

If you are unable to change the format when creating the .csv file you could use the Variable Modify String commands to removed those characters.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...