Excel xls file.
Rick Stanich
CMM Programming and Consulting, LLChttps://files.engineering.com/getfile.aspx?folder=0a0b15e8-4548-42f3-bc20-4660faa66f1e&file=57094-97_B_Op_2_of_2_03-04-24_3.xls
I am trying to write VBScript to save an active Excel file as a CVS file, The format of the Excel file needs to be retained.
See example Excel file (57094-97_B_Op 2 of 2_03-04-24_3.xls) and example CVS file (57094-97_B_Op 2 of 2_03-04-24_3.cvs) for comparing.
The Excel file is from a CMM...
Although the title of the post is misleading as I switched from DataGridView to simply reading an Excel file, there is a lot of information in the post about Excel files.
(Special thanks to Andrzejek)
thread1867-1828231: How to get data from DataGridView to a Listbox?
Rick Stanich
CMM...
Do we have a message system on this forum?
I'd like to send you a small gift card, just to say thank you.
Rick Stanich
CMM Programming and Consulting, LLC
I did get the code going and I not only got what I hoped, but it seems so much simplified now.
Thank you again!
Rick Stanich
CMM Programming and Consulting
I am getting an error at:
Do While .cells(intR, 1).value <> ""
Format error, it displayed "" (nothing displayed).
I changed the double quotes with "-1", this now shows the first part number but again an error.
I am using VS 2022.
Is it too much to ask to see your project so I can open it...
I did not know this; I am working with legacy Excel files.
I do know this has been done before, I have an EXE file that is doing what I am attempting to do, I just need to update things for new versions of OS and the CMM software. Unfortunately, the source code is unknown.
I will create a new...
Using method 1 of your two solutions.
"Select * From [Sheet1$] where [Part] is null or [Part] = '" & ComboBox1.Text & "' order by [Part]")
I get odd results.
See images Capture1.PNG and Capture2.PNG
Its adding a lot of "=" signs.
Also attaching my Excel workbook. (DataGridView is not retrieving...
What I am getting is: (Values from the first row).
Part - 00-294528
BoreSystem - 5x75
KidneySystem - 3x50
DatumATip - 3
Number of Bores - 9
What I need is what you posted: (Values from the 2nd row, those are my variables for a CMM language called PCM).
Part - 00-294528
bore_system - 5x75...
I'm going to move forward; I appreciate all the Help/Code you have provided.
I'll worry about looking for help later if I can't resolve this on my own.
Rick Stanich
CMM Programming and Consulting
I think there is another method:
Dim datDT As System.Data.DataTable = ExcelOleDb("V:\CMM Data Files\Micura CMM PCM Programs (252)\Inline Blocks\Parameters.xls", "Select * From [Dimensions$A:BZ] where [Part] = '" & ComboBox1.Text & "'")
By adding something similar to this?:
"select *...
WOW.
Something I did not understand or know, it seems that the first row (header row?) is automatically included in the population? (If I expressed that right).
Removing the Header Row Property by adding:
HDR=YES to the following.
.ConnectionString &= "Extended Properties = ""Excel 12.0...
In Excel, I can get a Row (to used range) and place that in a Listbox/Combobox as a Column using "Transpose".
See image of the excel worksheet: Excel file Data in a row.PNG
At runtime of my VB project, I select the first entry (Part), 00-294528 in my Combobox, as you helped, it places that...
The code works as you stated, I am now reading on how to get the entire row from "Part" in the Listbox transposed to a column.
I've been reading for a couple days now, and I found the Code Bank page.
Rick Stanich
CMM Programming and Consulting
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.