Home > Software engineering > Already using vb to control open the excel file, how to use in the process of another
Already using vb to control open the excel file, how to use in the process of another
Time:09-29
Such as: Outside the process wrote Dim Excel As Excel. Application Dim Workbook As Excel. The Workbook Dim Sheet1 As Excel. The Worksheet Dim sheet2 As Excel. The Worksheet Dim sheet3 As Excel. The Worksheet
In the process of a The Set of Excel=CreateObject (" Excel. Application ") Set Workbook.=Excel Workbooks. Open (App) Path & amp; "\ temp. XLS") The Set Sheet1=Workbook. Sheets (" Sheet1 ") Opened the temp. XLS and assignment, how to use this object in another process?
Again using the above statement?
CodePudding user response:
The Workbook or Sheet1 passed as an argument!
CodePudding user response:
The things into the form level variables or defined as global public variables, If it is to use in a module, class is defined as the form variables, use can be either private or dim; If anywhere in your project is likely to need, it is defined as a global public variables, such as:
In the standard module defined as global public variables, and then in your project all the modules can be called directly, Public Excel As Excel. Application . Public Workbook As Excel Workbook Public Sheet1 As Excel. The Worksheet Public sheet2 As Excel. The Worksheet Public sheet3 As Excel. The Worksheet
Then as in form1 or can be used directly in form2 sheet1, sheet2, sheet3...
CodePudding user response:
See, if using Getobject excel file has been opened, open multiple workbook, and then use workbooks (I) method to determine the use of the workbook
CodePudding user response:
The same program transfer object directly! Different programs to use the GetObject (),