Microsoft
Office 2000 Developer |
|
Using Visual SourceSafe with Documents and VBA Code
See Also
When using the VBA Source Code Control add-in, it's important to understand that Visual SourceSafe stores the binary document by using Visual SourceSafe directly and stores the VBA source code by using the VBA Source Code Control add-in. The VBA Source Code Control add-in cannot store the actual binary document. This affects how you use Visual SourceSafe to protect both documents and VBA code.
The following sections describe the important procedural differences for using Visual SourceSafe to protect both the document file and the associated VBA code files.
Creating the Initial Document
Let's say you are developing a new Excel document named Book1.xls. As a general process, you'll use the Visual SourceSafe application to add the document to source control.
To create and add your document to Visual SourceSafe
-
Create and save a new Excel workbook document named Book1.xls.
-
While the document is still open, start the Visual Basic Editor (ALT+F11), and click Add Project to SourceSafe. This adds the VSSODE control module to your project.
Tip You can specify the name and directory location for your new project folder.
-
Save the Excel document again to capture the new VSSODE module.
-
Close the document, and exit the Excel application.
-
Run Visual SourceSafe directly from the Start menu.
-
Add the Book1.xls document to your new project folder (using the Add Files command).
-
Exit Visual SourceSafe.
Visual SourceSafe now protects your document. Since the Book1.xls document is the fundamental basis for your new project, you might set up procedural rules so that only you and certain designated developers can modify it.
Modifying the Document
Occasionally, you'll want to modify the Book1.xls document to support additional VBA source code enhancements. As a general process, you'll check the document in and out of the Visual SourceSafe application.
To modify a document under source control
-
Run Visual SourceSafe directly from the Start menu.
-
Check out the document.
-
Open the document, and start the Visual Basic Editor (ALT+F11).
-
Get all the associated VBA files (using the Get Latest Version command on the Add-Ins menu) to update recent code changes.
-
Make changes to the document, and save the document.
-
Close the document, and exit the Excel application.
-
Check in the document to Visual SourceSafe.
-
Exit Visual SourceSafe.
Adding VBA Code Modules
You and other developers can also extend your document's functionality with VBA source code. For storing VBA code, Visual SourceSafe is conveniently available from within the Visual Basic Editor using commands from the VBA Source Code Control add-in. Although the Office document is stored directly in the Visual SourceSafe application, code modules are added to source control using the VBA Source Control add-in.
To create and add VBA code modules to source control
-
Run Visual SourceSafe directly (using the Run SourceSafe command on the Add-Ins menu or from the Start menu).
-
Check out the Office document.
-
Open the document, and start the Visual Basic Editor (ALT+F11).
-
Get all the latest code (using the Get Latest Version command on the Add-Ins menu).
-
In the Project Explorer, right-click the VBA project folder, and click Insert, and then click Module.
This creates a new VBA code module associated with the document. As a general practice, you can insert all of the required user forms, modules, and class modules at this time. Additional modules can always be added later using the same procedure.
-
Modify the code module as required.
-
Select the VBA project folder, and click Add Files to SourceSafe on the Add-Ins menu.
-
After selecting a project location directory, click OK, and finally select the objects you want to check in to Visual SourceSafe. When you click OK again, a temporary dialog box indicates that everything was added successfully. Then the Source code control status window displays the object names, check in/out status, and who currently owns them.
Tip The floating Source code control status window is also dockable. You can drag it to the left frame to share space with the VBA Project window and the Properties window.
Note If you are working on several projects, switching context between one project and the other does not update the Source code control status window. You can use the Refresh File Status command to immediately update this window.
-
Save the Excel document to capture the new VBA code modules.
-
Close the document, and exit the Excel application.
-
Check in the document directly into Visual SourceSafe.
-
Exit Visual SourceSafe.
Modifying VBA Code Modules
As you develop your VBA enhancements, you'll want to modify the actual VBA source code. Again, your code is stored by the VBA Source Code Control add-in, and the Office document is stored in the Visual SourceSafe application.
To modify your VBA code modules under source control
-
Run Visual SourceSafe directly from the Start menu.
-
Check out the document so you have a container for the VBA objects. (If you use the Get Latest Version command, be sure to check the option Make writeable.)
-
Open the document, and start the Visual Basic Editor (ALT+F11).
-
Get all the latest source code changes (using the Get Latest Version command on the Add-Ins menu).
-
Check out the VBA source code (using the Check Out command on the Add-Ins menu).
-
Make the changes to the VBA source code.
-
Check in the VBA source code (using the Check In command on the Add-Ins menu).
-
Close the document, and exit the Excel application.
-
Check in the document directly into Visual SourceSafe.
-
Exit Visual SourceSafe.