Home > Software engineering >  For help: the EXCEL work thin in the first table A1 cell content in VB form the Text above, the comp
For help: the EXCEL work thin in the first table A1 cell content in VB form the Text above, the comp

Time:09-19

For help: the EXCEL workbook in the first table A1 cell content is displayed in the VB form the Text above, the complete code, I am just learning to speak too deep, don't understand, ask the teacher to write out the code, and slowly understand, explain, the EXCEL workbook is running together with the program, so the question of whether there is no program to open, it has been running in the background, and running at the same time, there are two EXCEL workbook, table, table, B retains called a.

CodePudding user response:

Where is the teacher? No one answered me that,

CodePudding user response:

The building Lord, you have to distinguish "workbook" first, the concept of "worksheet",

Since you will read data workbook is already open, so which work must be clearly read book which piece of work of the table!
That is to say:
Must know the actual "workbook", the corresponding table name (this is the "text label") or table index number (this is the "number" value, not visible to the user),
Can make the correct reading through the COM interface to the data in a cell,

In addition you referred to in the ZhuTie "the EXCEL workbook is running together with the program",
Is it your own program starts, oneself use the code to open the document?

CodePudding user response:

I also have such problems, with o!!!!!!

CodePudding user response:

 
Private Sub Form_Load ()
Dim wb
The Set wb=GetObject (" C: \ Excel workbook. XLSX ")

'you say the first book,
MsgBox wb. Sheets (1) cells (1, 1)

'but is generally use this to specify the table name "Sheet work table" to operation, because you may not be able to determine your worksheet is which
MsgBox wb. Sheets (" Sheet work table "). The Range (" a1 ")
MsgBox wb Sheets! Sheet worksheet. Range (" a1 ")
MsgBox wb Sheets! Sheet worksheet. [a1]

MsgBox wb. Sheets (" Sheet work table ") cells (1, 1)
MsgBox wb. Sheets (" Sheet work table ") cells (1)
MsgBox wb. Sheets (" Sheet work table ") cells (1)

'to close the work table, put the following two lines uncomment
'the wb. Close
'Set wb=Nothing
End Sub

  • Related