471,082 Members | 919 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,082 software developers and data experts.

macro - how to open/close application file

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.vsSaveChang esYes)
Next
End Sub
thanks in advance

Ian

Nov 17 '05 #1
1 1096
Ian
Please disregard this posting as I realize it should have been put in the VB
newsgroup.

Ian

"Ian" <ib******@yahoo.com> wrote in message
news:Om**************@TK2MSFTNGP15.phx.gbl...
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.vsSaveChang esYes)
Next
End Sub
thanks in advance

Ian

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by jpodesta | last post: by
4 posts views Thread by Rich Wallace | last post: by
8 posts views Thread by Shooter4Life8 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.