Controlling visual source safe through visual basic 6.0

Posted on 2002-07-09
Last Modified: 2013-11-25
I want to write a code in VB to get files with a particular label under a VSS project (VSS lying on a server on network) and check all these files found in a new project.
Question by:vijayabadve

Expert Comment

ID: 7140465
You will want to reference the VSS object.  It is called Microsoft Sourcesafe 6.0 type library (or whatever version you have.  It should be there if you are using Source Safe from your machine.  I will try to work on some code for you.


Accepted Solution

gencross earned 100 total points
ID: 7140528
Here is a little code snippet that will open the VSS database.  You can then access the project(s) you need.

It is the best I can do at the moment.  It should give you something to go on.  Let me know if you need further assistance.

Dim objVSS As VSSDatabase
Set objVSS = New VSSDatabase
objVSS.Open "\\server1\ddrive\vb\vss\srcsafe.ini"
(use the path to your srcsafe.ini file)
LVL 100

Expert Comment

ID: 7140532
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 7140563
Many thanks for the code to start with.
But still my problems remains.
I want to access a particular project in VSS and get all
the files with a particular (Say release 4.4) label.
Then add these files in a new project.

Awaiting for the further help.
I am also trying to achieve this with the startup code.
So I am grateful to GENCROSS for the help.

Expert Comment

ID: 7140604
Here is some more code I just worked up that should show you have to do what you want.

Dim objVSS As VSSDatabase

Dim objItem As VSSItem
Dim objFile As VSSItem
Dim objNewItem As VSSItem
Dim objRoot As VSSItem

Set objVSS = New VSSDatabase

'Open SS database
objVSS.Open "\\server1\ddrive\vb\vss\srcsafe.ini"

'Open specific project
'To open a subproject just add it to the path ("$/TestProj/NewProj")
Set objItem = objVSS.VSSItem("$/TestProj", False)

'Cycle through all files in the project
For Each objFile In objItem.Items

    Debug.Print objFile.Name

'Create new project under the existing project
Set objNewItem = objItem.NewSubproject("NewProj", "Test proj")

'Or you can create new project in the root
Set objRoot = objVSS.VSSItem("$/", False)
Set objNewItem = objRoot.NewSubproject("NewProj", "Test proj")

Let me know if you need more help

Author Comment

ID: 7140620
Excellent. That's fantastic.
Now let me try to get files for a particular label only.
Could you please help me in that ?

Author Comment

ID: 7140628
Also the problem is , I know the roll directory name . I don't know how many sub directories are there inside it.
I just wanna dig the projects and get files under those with the label say "A" and share these files in a new directory

Expert Comment

ID: 7140649
By label to you mean file name?

Author Comment

ID: 7140664
No. One can assign a label to a particular version of a file. Say my main project has some subdirectories. There are different files under these different subdirectories. Some files have been labelled as 'Version 4.4'. Now I want to get all the files with labels 'Version 4.4' only. I don't want to get files not having this label. If you right click on a file and see history , you can see labels. You can lable a file by using label icon on the toolbar of VSS. I hope I could convey the question. Please ask me if I have failed.

Expert Comment

ID: 7140719
It becomes a little more complicated when you don't know the projects or how many sub projects there are you are going to want to recurse through all the sub projects.  I have found a good example of this at PSC.

There is also another problem.  I don't think you are going to be able to retrieve the label of the file.  You can set the label and comment from code, but do not think you can get it.
LVL 28

Expert Comment

ID: 7141148
LVL 49

Expert Comment

ID: 8002223
Hi vijayabadve,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept gencross's comment(s) as an answer.

vijayabadve, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.
DanRollins -- EE database cleanup volunteer

Expert Comment

ID: 8094205
Comment from expert accepted as answer

E-E Admin

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Dialogbox API leak? 18 108
Need more details 5 182
Please explain "Multi-Tenant Services" 5 107
Automatically generate a pdf file from an excel file and email out everyday 2 67
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question