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
Open Excel. From the File menu, save the new workbook document that appears as 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.
From the Start menu, run Visual SourceSafe.
Create a new project folder for your document.
Add the Book1.xls document to your new project folder (using the Add Files command).
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
- From the Start menu, run Visual SourceSafe.
- Check out the document.
- Open the document, and start the Visual Basic Editor (ALT+F11).
- On the Add-Ins menu, click Get Latest Version to get all the associated VBA files 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 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
From the Start menu, run Visual SourceSafe.
Check out the Office document.
Open the document, and start the Visual Basic Editor (ALT+F11).
On the Add-Ins menu, click Get Latest Version to get all the latest code.
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.
Modify the code module as required.
Select the VBA project folder, and, from the Add-Ins menu, click Add Files to SourceSafe.
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
- From the Start menu, run Visual SourceSafe.
- 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).
- On the Add-Ins menu, click Get Latest Version to get all the latest code changes.
- On the Add-Ins menu, check out the VBA source code.
- Make the changes to the VBA source code.
- On the Add-Ins menu, check in the VBA source code.
- Close the document, and exit the Excel application.
- Check in the document directly into Visual SourceSafe.
- 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