Welcome to Foxite.COM Community Weblog Sign in | Join | Help

Automating Visual Studio from VFP

Updating a file in a Visual Studio project from VFP is pretty straightforward. First up, get a reference to the project:
oVS = createobject("VisualStudio.Solution.8.0") && VS2005 
oVS.Open("C:\projects\example.sln")
oProject = oVS.Projects(1)
Each project has a ProjectItems collection: each can be a folder or a file. The items can be referenced by name, so this returns a reference to an XML file in the XML folder:
oDocument = oProject.ProjectItems("XML").ProjectItems("file.xml")
Each item has a URL property which indicates (for a file) the file name, but this is only available via the Properties collection:
cFilePath = substr(oDocument.Properties("URL").Value, 9) && strip off file:///
xmltocursor(alias(), "_cliptext") && Get XML on the clipboard
strtofile(_cliptext, cFilePath) && write to file.
You can do this while VS has the file open, it will notice and prompt you to reload the file.
Published Thursday, October 11, 2007 2:29 PM by stuartd

Comments

Anonymous comments are disabled