Open A Workbook

I co can create a procedure to open a workbook in Excel using the Open method of the Workbooks collection. Each time you open another workbook, Excel adds that workbook to the Workbooks collection. Similar to using the Open command on the File menu, opening another workbook using the Open method makes the workbook active.

Sixteen different parameters determine how Excel opens a workbook. Of these parameters, Excel requires only FileName. In addition, you only need to use the FileName, ReadOnly, Password, WriteResPassword, IgnoreReadOnlyRecommended, and AddToMRU parameters to open an Excel workbook. In addition, Excel requires several arguments when you open a text file. For more on opening text files, see the section "Open a Text File as a Workbook."

The FileName argument indicates the name of the workbook to open. You specify the workbook name for a workbook located in the same folder as the current workbook. For a workbook in another folder, you specify the workbook path as part of the file name: Workbooks.Open("C:\Workbooks\Budget.xls").

You can specify a value of True for the ReadOnly parameter to open the workbook as read-only. A False value opens the workbook as editable.

You can use the Password parameter to require users to enter a password to open a workbook. If you omit the password, and the workbook requires one, Excel prompts the user for a password before opening the file. Similar to the Password parameter, WriteResPassword requires users to enter a password to write in a workbook.

If you originally save a workbook with the Read-Only Recommended option selected, each time the workbook opens, Excel prompts you to open it as read-only. If you want to open the workbook without the prompt, you can specify a value of True for the IgnoreReadOnlyRecommended parameter.

Finally, you specify a value of True for the AddToMRU parameter if you want Excel to add a workbook to the recently used files list.

OPEN A WORKBOOK

OPEN A WORKBOOK

—n Create a new subroutine.

—0 Type Workbooks.Open.

—n Create a new subroutine.

Note: See Chapter 3 for information on creating subroutines.

—0 Type Workbooks.Open.

0 0

Post a comment