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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.


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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
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.…

738 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