Write a statement to declare a workbook object variable named wkbTute6 and store the address of (or point to) the “Tute6.xlsm” workbook.
Question
Write a statement to declare a workbook object variable named wkbTute6 and store the address of (or point to) the “Tute6.xlsm” workbook.
Solution
Here is how you can declare a workbook object variable named wkbTute6 and store the address of the "Tute6.xlsm" workbook:
Step 1: Declare the variable. In VBA, you declare a variable using the Dim statement. So, to declare a Workbook object variable, you would write:
Dim wkbTute6 As Workbook
Step 2: Assign the address of the workbook to the variable. You can do this using the Set statement and the Workbooks collection's Open method. The Open method takes the full path to the workbook file as an argument. Assuming that "Tute6.xlsm" is in the same directory as the macro, you would write:
Set wkbTute6 = Workbooks.Open("Tute6.xlsm")
So, the complete code would be:
Dim wkbTute6 As Workbook
Set wkbTute6 = Workbooks.Open("Tute6.xlsm")
This code declares a Workbook object variable named wkbTute6 and assigns it the address of the "Tute6.xlsm" workbook.
Similar Questions
Write a statement to declare a worksheet object variable named wksTute6 and store the address of (or point to) the “Sheet2” worksheet in the “Tute6.xlsm” workbook.
Write a statement to declare a range object variable named rngTute6 and store the address of (or point to) the range “A2” in the “Sheet2” worksheet in the “Tute6.xlsm” workbook.
Use the Set statement to point the worksheet object variable to the January worksheet in this workbook. Use the InputBox function to prompt the user for his/her name. Store the user’s response in the string variable called strName.
Which of the following is the correct syntax to open a workbook in VBA?*1 pointOpenWorkbook “filename”Workbooks.Open filenameOpen “filename” as workbookWorkbooks.Open “filename”
Which of the following is the correct syntax to close a workbook in VBA?*1 pointThisWorkbook.CloseWorkbooks.CloseWorkbook.CloseActiveWorkbook.Close
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.