Declare a Workbook object variable and assign the ActiveWorkbook object to it, so that subsequent code can work with the object variable: : Workbooks « Excel « VBA / Excel / Access / Word

Home
VBA / Excel / Access / Word
1.Access
2.Application
3.Data Type
4.Data Type Functions
5.Date Functions
6.Excel
7.File Path
8.Forms
9.Language Basics
10.Math Functions
11.Outlook
12.PowerPoint
13.String Functions
14.Windows API
15.Word
16.XML
VBA / Excel / Access / Word » Excel » Workbooks 




Declare a Workbook object variable and assign the ActiveWorkbook object to it, so that subsequent code can work with the object variable:
 
Sub workbook()
    Dim myWorkbook As Workbooks
    Set myWorkbook = ActiveWorkbook
    With myWorkbook
        'actions here
    End With
End Sub

 
Related examples in the same category
1.To select a Workbook object from the Workbooks Collection object
2.To avoid confusion, you can select a workbook unambiguously- if you know the name of the desired Workbook object
3.When you need to step through several objects in a collection, use a loop and a looping variable to represent the index of the object to be returned.
4.Work your way through the entire object hierarchy to set one property
5.Creating a New Blank Workbook
6.Stores the current SheetsInNewWorkbook property, sets the SheetsInNewWorkbook property to 12, creates a new workbook (with those 12 worksheets), and then restores the SheetsInNewWorkbook setting to its previous value
7.Values for the UpdateLinks Argument
8.Opens the workbook named Plan.xls stored in the D:\Planning folder, providing the password for opening the workbook
9.Opens the text file named Data13.txt in the folder z:\transfer using an exclamation point (!) as the delimiter character
10.Closing All Open Workbooks
11.Sharing a Workbook
12.Working with Worksheets to add a worksheet
13.Copying or Moving a Worksheet
14.Moves the worksheet named Homes from the workbook named Planning.xls to the workbook named Building Schedule.xls, inserting the worksheet before the first existing worksheet in the workbook
15.Prints the first two pages of the worksheet named Summary in the workbook named Planning.xls to a file named Planning Summary.prn in the network folder \\server\to_print:
16.Returns the text in the active cell in the first window open on the workbook named Planning.xls:
17.Creating a Named Range from Workbooks
18.Deleting a Named Range
19.To apply a read-only recommendation to a workbook, set its ReadOnlyRecommended property to True
20.Activating a Window
21.Arranging and Resizing Windows
22.Use For...Next loop through Workbooks
23.Add Workbooks and save it as a new file
24.Use the return value of the Add method to create an object variable that refers to the new workbook
25.The Add method allows you to specify a template for the new workbook.
26.To add an existing workbook file to the Workbooks collection, you use the Open method
27.Getting a Filename from a Path
28.To see if the workbook is already a member of the Workbooks collection
29.Activate Workbook
30.Files in the Same Directory
31.Overwriting an Existing Workbook
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.