473,320 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 1157
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Carl | last post by:
Please can anyone tell me how I can create a macro to save the results of a query as an excel file? The query is called Student List and I would like to save it to "My Documents". We have had...
0
by: jpodesta | last post by:
Hello- I am fairly new to MS Access and would like to use some macros in .xls in an Access Module. I have tried to do this on my own but failed to make it work. I have included the xls macros...
4
by: Rich Wallace | last post by:
Is there a way to open an Excel file and either respond to or supress the Macro warning window via VB.NET? Dim oExcel As Excel.Workbook Dim sFilePath As String = "C:\DailyReport.xls" oExcel...
8
by: Shooter4Life8 | last post by:
I am trying to run a macro from my VB.NET program. Here is my code. Dim myAccess As Access.Application Dim allMacro As String = "ALL-Macros" myAccess.DoCmd.RunMacro(allMacro) I get the error....
0
by: guptasourav | last post by:
I am opening an Excel file on my server, and saving it with some other name and then trying to coping the new excel to my local machine. If i use a simple Excel(without macro but with password) it...
0
by: modularmix | last post by:
Does anyone know how to run the Excel Macro for two different spreadsheets in parallel. Here is the code that works sequentially. Workbooks.Open Filename:="C:\Documents and...
1
by: arun0580 | last post by:
I am running a VBA macro application in Microsoft Excel 97 under Windows XP -Service Pack 1 to, 1.Open an Excel work book . 2.Update a value in a cell 3.Save and close the file. I need to...
0
by: semme001 | last post by:
I have a macro that ran normally for about 6 cycles but apparently developed an error? It appears to stall on the second loop when it attempts to open the named workbook. Any suggestions would be...
7
by: NeverLift | last post by:
This is probably answered elsewhere, but I've searched the Web and VBA for Excel manual, find no answers. I have a VBA-coded macro in an Excel workbook that is to open another existing workbook --...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.