Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DDE excel read/display

Status
Not open for further replies.

cryptotech

Technical User
Nov 9, 2007
26
US
I'm hoping one of the gurus here can explain a way to accomplish this simple task.

I've read many examples of DDE scripts, but haven't found a simple one for what I need (or it's probaby going completely over my head)

I have an excel spreadsheet with 5 columns of data.

First column is a 5 digit number.

I would like to bring up a sdlginput box, input the 5 digit number (12345), and display in a usrmsg the contents of all the columns in the same row including the column header
e.g.
After entering "12345" in my input box the following user message would display:

12345
Station: "data from column 2"
Location: "data from column 3"
Owner: "data from column 4"
Active: "data from column 5"

I do not need to see the spreadsheet, but just have the data read and displayed in a user message in my terminal window.

Sort of a widget where I can cross reference information quickly at the press of a metakey or dialog button.

thanks in advance for any help!

 
Try starting with the script at the below link:


You would want to modify it so that the if stricmp command looks for the five-digit number entered into the sdlginput dialog. You would also want to take these two lines from the else clause of that if statement:

strfmt sRowCol "R%dC%d" iRow iCol2
dderequest LinkVar sRowCol szText ;Read data from spreadsheet, current row, column 2

and move them to just above the exitwhile command immediately after the if stricmp command. Actually, you would want to paste those two lines four times and modify the strfmt command to replace iCol2 with the values "2" "3" "4" and "5" respectively so that the values of those columns for the current row can be read. You'll also need to give each of the four dderequest commands a unique variable so each column has its own variable to display the cell information in your dialog.

 
Thanks very much, this raises more questions though.

So there is no way to have the excel file read without having the file already opened?

This defeats the purpose if I have to find the file and open it then run the script.

From what I've done so far I cannot link to excel without already having the spreadsheet open.
If its open the script hangs up on strfmt for iCol2

To make this simpler while im learning ive just made the spreadsheet with 2 columns. Column A is the station number, column B is the location.

Not sure what to put in the stricmp line if I want it to find the 4 digit station number that was input.

Not sure how to assign the value returned for column 2 of the same row of the station input into the usermsg.

Of course these questions won't matter if I have to find and open the spreadsheet before running the script.
Perhaps I'll need to find another way..maybe create a text file and have one line of text with the whole row of data that was in excel that can be read and returned in a usermsg.
-sigh-

thanks again for any input,

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top