Using Visual SourceSafe with Documents and VBA Code

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

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 Office Document

  • Modifying the Office Document

  • Adding VBA Code Modules

  • Modifying VBA Code Modules

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

  1. Create and save a new Excel workbook document named Book1.xls.

  2. 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.

  3. Save the Excel document again to capture the new VSSODE module.

  4. Close the document, and exit the Excel application.

  5. Run Visual SourceSafe directly from the Start menu.

  6. Add the Book1.xls document to your new project folder (using the Add Files command).

  7. 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

  1. Run Visual SourceSafe directly from the Start menu.

  2. Check out the document.

  3. Open the document, and start the Visual Basic Editor (ALT+F11).

  4. Get all the associated VBA files (using the Get Latest Version command on the Add-Ins menu) to update recent code changes.

  5. Make changes to the document, and save the document.

  6. Close the document, and exit the Excel application.

  7. Check in the document to Visual SourceSafe.

  8. 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

  1. Run Visual SourceSafe directly (using the Run SourceSafe command on the Add-Ins menu or from the Start menu).

  2. Check out the Office document.

  3. Open the document, and start the Visual Basic Editor (ALT+F11).

  4. Get all the latest code (using the Get Latest Version command on the Add-Ins menu).

  5. 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.

  6. Modify the code module as required.

  7. Select the VBA project folder, and click Add Files to SourceSafe on the Add-Ins menu.

  8. 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.

  9. Save the Excel document to capture the new VBA code modules.

  10. Close the document, and exit the Excel application.

  11. Check in the document directly into Visual SourceSafe.

  12. 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

  1. Run Visual SourceSafe directly from the Start menu.

  2. 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.)

  3. Open the document, and start the Visual Basic Editor (ALT+F11).

  4. Get all the latest source code changes (using the Get Latest Version command on the Add-Ins menu).

  5. Check out the VBA source code (using the Check Out command on the Add-Ins menu).

  6. Make the changes to the VBA source code.

  7. Check in the VBA source code (using the Check In command on the Add-Ins menu).

  8. Close the document, and exit the Excel application.

  9. Check in the document directly into Visual SourceSafe.

  10. Exit Visual SourceSafe.