Home > Software engineering > Vb assignment right the first time, the second assignment 1004 error, ask the great spirit guide!!!!
Vb assignment right the first time, the second assignment 1004 error, ask the great spirit guide!!!!
Time:09-25
Private Sub CmdJoinExcel_Click () ' Dim xlsApp As Object Dim xlsBook As Object Dim xlsSheet As Object Dim xlsApp As New Excel. Application On the Error Resume Next 'Error changing trap The Set xlsApp=GetObject (App) Path, "et. Application") If Err Then Err. Clear 'removal Err object field The Set xlsApp=CreateObject (" et. Application ") If Err Then Exit Sub 'Exit the program, in order to avoid entering the error handler End the If End the If XlsApp. Visible=True The Set xlsBook=xlsApp. Workbooks. Add LX=(ComLX. Text) The Select Case LX The Case Is=1 Set xlsSheet=xlsBook. Worksheets (1) 'setting work table 1 Cells (1, 1)="basic parameters" : Cells (2, 1)="name" : Cells (2, 2)="open type deep groove ball optimized parameters" : Cells (3, 1)="series," The Case Is=2 Set xlsSheet=xlsBook. Worksheets (2) 'setting work table 2 Cells (1, 1)="basic parameters" : Cells (2, 1)="name" : Cells (2, 2)="sealed deep groove ball optimized parameters" : Cells (3, 1)="series," The Case Is=3 The Set xlsSheet=xlsBook. Worksheets (3) 'setting work table 3 Cells (1, 1)="basic parameters" : Cells (2, 1)="name" : Cells (2, 2)="with dust cover deep groove ball optimized parameters" : Cells (3, 1)="series," End the Select XlsApp. Save 'Save the workbook XlsBook. Close 'Close work thin file XlsApp. Quit 'end excel object Set xlsApp=Nothing 'release xlapp object to memory space The Set xlsBook=Nothing The Set xlsSheet=Nothing End Sub
The great god, the question now is to excel assignment for the first time, the second time they became empty, not the assignment, please answer, thank you very much!
CodePudding user response:
The building Lord, Mars? This code on earth can you run?