macro - how to open/close application file

  • Thread starter Thread starter Ian
  • Start date Start date
I

Ian

I have just begun to to learn how to write macros in VC++. For learning
purposes, I would like to implement a macro that accesses all files in a
'test' project and makes a series of changes to these files. I am able to
identify each file in my project and then open the file. But I have yet to
figure out how to close the file. Could someone kindly tell me how to close
a file? The following BASIC code illustrates my first efforts:

Sub replaceMacro()
Dim oItems As ProjectItems = DTE.ActiveSolutionProjects(0).ProjectItems
Dim oI As ProjectItem
For Each oI In oItems
Dim oFilename As String = oI.Name()
oI.Open(vsViewKindPrimary)

' close file
' the following line fails and generates the error message
' "Object reference not set to an instance of an object
DTE.ActiveDocument.Close(vsSaveChanges.vsSaveChangesYes)
Next
End Sub


thanks in advance

Ian
 
Please disregard this posting as I realize it should have been put in the VB
newsgroup.

Ian
 
Back
Top