473,804 Members | 2,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ActiveSolut ionProjects(0). ProjectItems
Dim oI As ProjectItem
For Each oI In oItems
Dim oFilename As String = oI.Name()
oI.Open(vsViewK indPrimary)

' close file
' the following line fails and generates the error message
' "Object reference not set to an instance of an object
DTE.ActiveDocum ent.Close(vsSav eChanges.vsSave ChangesYes)
Next
End Sub
thanks in advance

Ian

Nov 17 '05 #1
1 1173
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******** ******@TK2MSFTN GP15.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.ActiveSolut ionProjects(0). ProjectItems
Dim oI As ProjectItem
For Each oI In oItems
Dim oFilename As String = oI.Name()
oI.Open(vsViewK indPrimary)

' close file
' the following line fails and generates the error message
' "Object reference not set to an instance of an object
DTE.ActiveDocum ent.Close(vsSav eChanges.vsSave ChangesYes)
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
24206
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 some problems with our database crashing. We would therefore like another way to have access to basic student data and thought we automatically save the results of this query when we close Access. Any suggestions on how we could do this would be...
0
1749
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 and the module as well as where I would like the macros to run. Any input on how to make this work would be appreciated. This would automate a former 3 step process into one process.
4
10107
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 = GetObject(sFilePath) --> Throws Macro warning window oExcel.Unprotect("password")
8
4687
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. "An unhandled exception of type 'System.NullReferenceException' occurred in
0
1580
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 works properly but if i use a macro and make the excel password protected then it does not allow me to open it. It does not give any exception but on reaching to "oWB = oXL.Workbooks.Open(" it hangs up. Private Sub Page_Load(ByVal sender As...
0
1839
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 Settings\Administrator.SLB_EUROPE\Desktop\norm ops 150607.xls" ' Select Asset & Portfolio Parameter sheet Sheets("Asset & Portfolio Parameter").Select ' Change the number of iterations Range("D7").Select
1
2281
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 repeat the steps 1,2,3 for 1,00,000 times. But after executing the process around 32,000 times the Excel application crashes.The whole OS hangs. And a message box appears As Run time error -2147467259 (80004005) ", method 'open' of object workbook's...
0
981
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 most helpful!! Here is the code I am working with. Sub Update1() ' ' Macro4 Macro ' Dim SaveString As String Dim sstr As String Dim pptr As String
7
93672
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 -- a .xls file, not .csv -- copy data from it, paste that into the original workbook where the macro resides, then close the source workbook. If I use the debugger to step through the macro -- putting a breakpoint at its first executable line, run...
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9571
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10318
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9132
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6845
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2976
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.