Share via


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 Microsoft® Visual SourceSafe™ stores the binary document by using Visual SourceSafe directly and stores the Microsoft® Visual Basic® for Applications (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

Suppose you are developing a new Microsoft® Excel document named Book1.xls. As a general process, you will use the Visual SourceSafe application to add the document to source control.

To create and add your document to Visual SourceSafe

  1. Open Excel. From the File menu, save the new workbook document that appears as 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. From the Start menu, run Visual SourceSafe.

  6. Create a new project folder for your document.

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

  8. Exit Visual SourceSafe.

Visual SourceSafe now protects your document. Because the Book1.xls document is the fundamental basis for your new project, you might set up procedural rules so only you and certain designated developers can modify it.

Modifying the Document

Occasionally, you will 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. From the Start menu, run Visual SourceSafe.
  2. Check out the document.
  3. Open the document, and start the Visual Basic Editor (ALT+F11).
  4. On the Add-Ins menu, click Get Latest Version to get all the associated VBA files 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 can 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 Microsoft® 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. From the Start menu, run Visual SourceSafe.

  2. Check out the Office document.

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

  4. On the Add-Ins menu, click Get Latest Version to get all the latest code.

  5. In the Project Explorer, right-click the VBA project folder, 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, from the Add-Ins menu, click Add Files to SourceSafe.

  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. From the Start menu, run Visual SourceSafe.
  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. On the Add-Ins menu, click Get Latest Version to get all the latest code changes.
  5. On the Add-Ins menu, check out the VBA source code.
  6. Make the changes to the VBA source code.
  7. On the Add-Ins menu, check in the VBA source code.
  8. Close the document, and exit the Excel application.
  9. Check in the document directly into Visual SourceSafe.
  10. Exit Visual SourceSafe.

See Also

Using Source Code Control | Setting Up Visual SourceSafe | Choosing the Right Source Code Control Add-In | Using the Visual SourceSafe Add-In with the Visual Basic Environment | Using Source Control with Access