LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Barcode input to excel and read data

Solved!
Go to solution

Hello,

 

I am creating a program where I would scan a barcode into LV and from there LV scans an excel spreadsheet for that barcode and returns the data from that row. I found an example online that helps with the barcode number find in excel but I am not coming up with a strange issue when trying to display the information from that row. My program finds the correct barcode in every case. Only when I enter the number from row 1 will the row information be correct. When I enter in information from row 2 lets say it displays the row information from row 3. When I enter in row 3 the program display row 5 information. Attached is my rough copy of code(this is my first stab at Active X controls so bear with it please) and an example spreadsheet I have created with some information about how the program is working. I have checked other posts for similar problems and couldnt find one that hepls with my particular issue. I have also checked the excel specific thread but found no links to code that can help. Any help is appreciated. Im thinking I am over looking something but since this is my first shot at this type of programming im not quite sure what it is. Thanks in advance for any information.

Download All
0 Kudos
Message 1 of 9
(5,363 Views)

Can't read your VI since it is 2011.

0 Kudos
Message 2 of 9
(5,360 Views)

Why did you start a new thread. You had already started one: http://forums.ni.com/t5/LabVIEW/barcode-input-than-read-from-excell/m-p/2002549

 

Let's keep all discussion here.

0 Kudos
Message 3 of 9
(5,356 Views)

The other thread has no VI nor Excel.

I'm curious what is going on in the VI, but I can't open it.

0 Kudos
Message 4 of 9
(5,353 Views)

Have you tried putting the key focus to the "Barcode Input" string control?

0 Kudos
Message 5 of 9
(5,347 Views)
Solution
Accepted by topic author Branderegg

@nyc_(is_out_of_here) wrote:

The other thread has no VI nor Excel.

I'm curious what is going on in the VI, but I can't open it.


It's the same question, except this time the OP provided a follow-up saying, "OK, here's what I got, and it does this. Why?" I would have just continued in that thread. Whatever.

 

In any event, your error is that you do not want to wire the found row to the set of Range.Item(get) methods. You need to wire a constant of 1 to the "Row" parameters for both of those. Since you are operating on a found range, you do not want to change the row.

 

As it stands right now your VI does not close Excel when done. The Excel process remains running in the background. Please review the example that ships with LabVIEW, which closes Excel when done.

0 Kudos
Message 6 of 9
(5,337 Views)

Thanks for the solution that works great. Sorry for starting the new thread it skipped my mind that I had put one up there yesterday. I knew it was somethign that I just overlooked. Thanks again.

0 Kudos
Message 7 of 9
(5,332 Views)

The "Find" method returns a range and you want to get an item out of that Range, not out of the entire worksheet.  Set the RowIndex to 1 and it will work as you expect, because the range returned by Find has already selected the correct row.

 

By the way, you need to close the Excel.Application reference, and you may want to use the "Quit" method to exit Excel first.

 

EDIT: Looks like I took just a few minutes too long to post, and the right answer made it in before I finished!

0 Kudos
Message 8 of 9
(5,328 Views)
0 Kudos
Message 9 of 9
(4,984 Views)