Excel deleting xml item problem

I have an excel macro (in an add-in) that is called by the main excel macro 
that is deleting various items in an xml file

When it gets to the last line as below it generates the following message

“An unhandled error occurred: Object variable or with block not set”

the variable is dimensioned see Dim statement that I have copied here.  This 
has worked for some time with no problem but suddenly out of the blue 
generates this error.  I have tried replacing the xml file with a copy, also 
tried replacing the add-in with a copy (in case either have been corrupted).  
The error description is per “Err.Description”

Dim oInstNode As IXMLDOMNode

Set oReplacedNode = oxml.selectSingleNode("/InstrumentList")

 Set oCheckNode = oReplacedNode.selectSingleNode("Instrument[OMR='" & 
OMRCode & "']")

Any ideas will be gratefully received

-- 
with kind regards

Spike
0
Utf
2/24/2010 11:34:03 AM
excel.programming 6508 articles. 2 followers. Follow

3 Replies
846 Views

Similar Articles

[PageSpeed] 47

I think the whole piece of code might help

the row varialble Set oReplacedNode  shows "Nothing" which i guess is the 
problem

Public Sub delInstrumentCode(ByVal OMRCode As String, ByVal filename As 
String)
    Dim oxml As DOMDocument
    Dim oInstNode As IXMLDOMNode
    Dim oReplacedNode As IXMLDOMNode
    Dim bLoadSuccess As Boolean
    Dim ofs As FileSystemObject
    
    'InstrumentList/Instrument/OMR
    'InstrumentList/Instrument/desc
    
    On Error GoTo errHandle
    
    Set ofs = New FileSystemObject
    Set oxml = New DOMDocument
    
    If Not ofs.FileExists(filename) Then
        MsgBox "The file " & filename & "Cannot be found"
        Exit Sub
    End If
    
    bLoadSuccess = oxml.Load(filename)
    
    If Not bLoadSuccess Then
        MsgBox "The file " & filename & " failed to load correctly." & vbCr 
& _
               "Error: " & oxml.parseError.reason, vbCritical, "Save Ticker 
History Error"
        Exit Sub
    End If
        
    Set oReplacedNode = oxml.selectSingleNode("/InstrumentList")
    
    Set oInstNode = oReplacedNode.selectSingleNode("Instrument[OMR='" & 
OMRCode & "']")
    If Not oInstNode Is Nothing Then
        Call oReplacedNode.removeChild(oInstNode)
        oxml.Save filename
    End If

    Set oxml = Nothing
Exit Sub
errHandle:
    MsgBox "An unhandled error occured: " & Err.Description, vbCritical
End Sub
-- 
with kind regards

Spike


"Spike" wrote:

> I have an excel macro (in an add-in) that is called by the main excel macro 
> that is deleting various items in an xml file
> 
> When it gets to the last line as below it generates the following message
> 
> “An unhandled error occurred: Object variable or with block not set”
> 
> the variable is dimensioned see Dim statement that I have copied here.  This 
> has worked for some time with no problem but suddenly out of the blue 
> generates this error.  I have tried replacing the xml file with a copy, also 
> tried replacing the add-in with a copy (in case either have been corrupted).  
> The error description is per “Err.Description”
> 
> Dim oInstNode As IXMLDOMNode
> 
> Set oReplacedNode = oxml.selectSingleNode("/InstrumentList")
> 
>  Set oCheckNode = oReplacedNode.selectSingleNode("Instrument[OMR='" & 
> OMRCode & "']")
> 
> Any ideas will be gratefully received
> 
> -- 
> with kind regards
> 
> Spike
0
Utf
2/24/2010 11:41:01 AM
You may of changing your error trapping option there are 3 option in
the following VBA menu


Tools - Options - General - Error trapping.

I usually set my PC to trap on all errors.  Selecting unhandled errrors
often causes proplems because athe code skips past 1 error and gets
stuck on a 2nd error and people can't figure out how to solve resolve
the 2nd errror.  I like to fix the rott causes of problems and fix the
1st error.


-- 
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=182129

[url="http://www.thecodecage.com"]Microsoft Office Help[/url]

0
joel
2/24/2010 11:53:15 AM
found the error - it was referencing the wrong file.  Fairly basic i guess, 
it had been hard coded in by someone!
-- 
with kind regards

Spike


"Spike" wrote:

> I think the whole piece of code might help
> 
> the row varialble Set oReplacedNode  shows "Nothing" which i guess is the 
> problem
> 
> Public Sub delInstrumentCode(ByVal OMRCode As String, ByVal filename As 
> String)
>     Dim oxml As DOMDocument
>     Dim oInstNode As IXMLDOMNode
>     Dim oReplacedNode As IXMLDOMNode
>     Dim bLoadSuccess As Boolean
>     Dim ofs As FileSystemObject
>     
>     'InstrumentList/Instrument/OMR
>     'InstrumentList/Instrument/desc
>     
>     On Error GoTo errHandle
>     
>     Set ofs = New FileSystemObject
>     Set oxml = New DOMDocument
>     
>     If Not ofs.FileExists(filename) Then
>         MsgBox "The file " & filename & "Cannot be found"
>         Exit Sub
>     End If
>     
>     bLoadSuccess = oxml.Load(filename)
>     
>     If Not bLoadSuccess Then
>         MsgBox "The file " & filename & " failed to load correctly." & vbCr 
> & _
>                "Error: " & oxml.parseError.reason, vbCritical, "Save Ticker 
> History Error"
>         Exit Sub
>     End If
>         
>     Set oReplacedNode = oxml.selectSingleNode("/InstrumentList")
>     
>     Set oInstNode = oReplacedNode.selectSingleNode("Instrument[OMR='" & 
> OMRCode & "']")
>     If Not oInstNode Is Nothing Then
>         Call oReplacedNode.removeChild(oInstNode)
>         oxml.Save filename
>     End If
> 
>     Set oxml = Nothing
> Exit Sub
> errHandle:
>     MsgBox "An unhandled error occured: " & Err.Description, vbCritical
> End Sub
> -- 
> with kind regards
> 
> Spike
> 
> 
> "Spike" wrote:
> 
> > I have an excel macro (in an add-in) that is called by the main excel macro 
> > that is deleting various items in an xml file
> > 
> > When it gets to the last line as below it generates the following message
> > 
> > “An unhandled error occurred: Object variable or with block not set”
> > 
> > the variable is dimensioned see Dim statement that I have copied here.  This 
> > has worked for some time with no problem but suddenly out of the blue 
> > generates this error.  I have tried replacing the xml file with a copy, also 
> > tried replacing the add-in with a copy (in case either have been corrupted).  
> > The error description is per “Err.Description”
> > 
> > Dim oInstNode As IXMLDOMNode
> > 
> > Set oReplacedNode = oxml.selectSingleNode("/InstrumentList")
> > 
> >  Set oCheckNode = oReplacedNode.selectSingleNode("Instrument[OMR='" & 
> > OMRCode & "']")
> > 
> > Any ideas will be gratefully received
> > 
> > -- 
> > with kind regards
> > 
> > Spike
0
Utf
2/24/2010 12:34:01 PM
Reply:

Similar Artilces:

Auto delete windows mail?
I'm using Windows mail with Vista. My junk folder has auto emptied twice in the last two months. I can't figure out why. Any help out there? -- marty "srmarty" <srmarty@discussions.microsoft.com> wrote in message news:D87CB396-6251-45C3-BC9A-DF77952EC095@microsoft.com... > I'm using Windows mail with Vista. My junk folder has auto emptied twice > in > the last two months. I can't figure out why. Any help out there? > -- > marty Tools>options>advanced tab>maintenance button. -- Regards Steve. MS-MVP. MAIL. ...

Problems with Public Folders replication
Hi guys, Some problems here. We have decided to install Exchange server 2003 SP1 on a new hardware with W2k3 SP1 on a new DC (yes, I know it is a bad practice, but...) instead of old Exchange server 2003 SP1 on an old DC on an old hardware. New one (additional) DC was brought live (with some minor problems, DNS, time, as always) without FSMO delegation (for now). Replication of users' accounts was smooth. Logs clear. After Exchange 2003 SP1 installation (with some DNS manipulations) also all was Ok. Dcdiag Ok. In ESM all Exchange servers are visible (old and new). So I have started ...

Exchange update problem
I have tried to upgrade exch2k3 sp1 to sp2, but the update fails with "the file pcproxy.dll is in use, and setup cannot identify the app or srvc. setup cannot continue" Any clues/ideas/suggestions? Please. -- ----------------------------------------------------------------------------------------------------------------------- This message has been checked for all known viruses. The information contained in this e-mail and any attachments is confidential and may be the subject of legal, professional or other privilege. It is intended for the named addressee only and may not ...

multiple Domain name delivery problem
hi, I currently have Exchange Server 2003 Build 7638:2 SP2,. We have multiple domain names being delivered to the exchange store. I have nothad any problems, but i currently have one user that is not receiving emails with attachments from one certain "internet" sender to one of her email addresses, but the other address works fine & if they send emails without attachments, everything works fine from either address. I have had the user send them message with attachments to me & the user with the problem & i get the message, but not the other user! I even use message...

docmd.transfertext problem
Hi, I am using access 97 and tried to import a csv file to the mdb table. I run a code as following: DoCmd.TransferText acImportDelim, "Specification4", "input", DEFAULT_PATH & "online.txt", 1 In online.txt, there is a field which is 10 digit number and I specified it as a double datatype in the specification4. After the import, I found out that the 10 digit number data in the field get empty in the destined table while other fields are all right. Therefore I import manually using specification4 instead of running code. This time the 1...

Excel 2007
When I select cells to copy as a picture in Excel 2007, the resolution is terrible. Text and objects with shadow's are very blotchy when pasting the picture. How do you change the resolution of a 'Copy Picture'? ...

Input Excel 'Password to Open' through control in access form
Hi All, We know,Excel has prompt password to open it files. Is it possible to create a code that can supplies the excel prompt password?.So that when we open the excel file through our access control in a form, the excel files can be opened automatically.But when the excel files opened from its default icon,it will prompt a password first. ...

SQL deadlock problem
I am currently having a big issue with sql deadlocking on the PrincipalObjectAccess table. The last few months I have been working on a synchronization process using a Biztalk orchestration. The sync uses the crm webservices to create and update account and contact records in CRM. But now deployment to the production environment gives me some problems. It seems that when trying to update account records (which is one of the first actions in the sync process) the webservice gives me Generic SQL errors and SQL timeouts. After extensive profiling and tracing in SQL I found that there are...

Excel not Access
I have designed an Access database that holds records relating to my stores audit results going back for about 5 years plus a load more information relating to these stores. This was used to produe a pack once a month, however a change in senior management means that I have got to shelve this and prodce a similar pack in Excel. The idea would be that the user could select a month or a 12 mnth date range that would produce data that could then be used to populate a number of excel templates that have been designed. Having not used excel for years I would be grateful for any suggestion...

How to keep format when importing Excel into SQL.
Can anybody help me please? When I import Excel file into SQL, a field that formated as 0000000000 (custom), loosing leading zeros. I tried to change data type in SQL after importing. No luck. I appretiate any help. See if using IMEX=1 helps: http://pratchev.blogspot.com/2007/10/importing-excel-data-into-sql-server.html -- Plamen Ratchev http://www.SQLStudio.com Plamen, I tried this, but got an error: "The OLE DB provider "Microsoft.Jet.OLEDB.4.0" has not been registered." Thank you very much for looking into this. "Plamen Ratchev" wr...

Auto-format in Microsoft Excel.
Each time i try to enter a number range, for example, 8- 10, in Excel, it constantly re-formats it to a date. If I change the formatting to "General" it turns it into a random number, usually 38209. I would like to turn off ALL auto-formatting, but that's probably asking too much. How do I disable this frustrating feature? thanks. Hi Paul When you enter "8-10" in a cell, that's not strictly a number but Excel thinks you mean a date so converts it as such. A date is a number and in your example the number 38209 represents August 10 2004 which is not a ra...

How to change font size on formula bar in Excell 2007
I don't find Tools>Options>General (as suggested in other post answers) in Excel 2007. On the Office button there is an Excel Options but it doesn't provide a method of changing font size on the office but. My font is so small I can barely see it. Office button>ExcelOptions>Popular tab>in the "When creating new workbooks" section, choose font and font size -- Kind regards, Niek Otten Microsoft MVP - Excel "jimwillie" <jimwillie@discussions.microsoft.com> wrote in message news:588AAC05-0F52-404E-AA01-128E70E02D0B@microso...

Invalid XML error when I open customization setting
I have a problem when I try to open customization setting after I import an entity. The system errored "Invalid XML" "The XML passed to the platform is not well-formed XML". Please recommend how to resolve this problem. Thanks. ...

Opening Excel Workbooks
I'm running into an issue where if I click on an Excel file through My Documents, it doesn't automatically bring it up. I get the toolbar but the actual spreadsheet doesn't appear on the screen. I have to click on the taskbar to get it to pop up. If I already have Excel active and I open a file through Excel, this doesn't happen. Any ideas? Here is a similar thread: http://www.excelforum.com/showthread.php?s=&threadid=237195 Rolli -- Message posted from http://www.ExcelForum.com Hi, Take a look at Tools-Options-General tab- uncheck ignore other application...

Unexpected error message on closing an Excel file
Suddenly I am getting the following message when I try to close a workbook: "Your formula contains an invalid external reference to a worksheet. Verify that the path, workbook, and range name or cell reference are correct, and try again" The mysterious thing is that it does not happen consistently and that, after I click OK after the above message, I can still save the file. What might be the cause of this error message and can the "invalid reference" be tracked down using one of the utility add-ins such as J. Walkenbach's PUP? If it only happens when you close ...

Strange Access Denied Problem with Windows 7
I got a new computer about six months ago that came with Windows Vista Home Premium 64bit. Before that I had done all of my .NET development either on an XP Pro VM or my former XP Pro computer at home. Shortly after getting my new computer at home, I also got a license for VMWare to be able to test my software on multiple platforms and configurations. I had wrote an application originally in VB.NET that was a simple backup utility. It supports mutiple backup configurations. Any given copnfiguration would define a backup which would be a list of files to backup, a list of folders to ...

help with simple maths in excel
I want to do a simple arithmatic excercise in excel for my grand daughter. It is stuff like 2+2 =4 Smart me has hit a problem at the first hurdle... I need to put 2 in one cell the + in another cell and then 2 in another = in another and then she puts the answer in the next one. So the above would have 4 cells completed and she would put the answer in the 5th one. When I use the + or = sign in a cell of its own it (excel) thinks I am doing an equation, is there a way around this? I will work on the answer like if she gets it correct or wrong how I will do that...a sound or som...

How To Copy MS Word mailing labels into Excel
I have a word doc that I want to put into Excel. I want to add some more fields to the names and addresses. Is this simple or do I have to learn how to program? Michael Rodriguez City of Grand Prairie Michael, have you tried to copy and paste the data into excel? -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Feedback on answers is always appreciated! Using Excel 2000 & 97 ** remove news from my email address to reply by email ** "Michael Rodriguez" <mrodrigu@gptx.org> wrote in messa...

How do I use traffic lights in excel
I am wanting to use traffic lights in excel that change colour based on the result of a variance cell, ie if the result of the cell is 10 make the traffic light green, if it is 20 make the traffic light amber, if the result is 30 make the traffic light red. How do I do this? Shorty Format>Conditional Formatting>Cell Value is: Note: you can add up to 3 conditions(4 if you count default) Gord Dibben Excel MVP On Wed, 22 Dec 2004 16:35:03 -0800, Shorty <Shorty@discussions.microsoft.com> wrote: >I am wanting to use traffic lights in excel that change colour based on the &g...

Border problems
Not sure why all of a sudden all my borders in my tables created with Publisher can only be white. No other color will show when selected. Opening a pub file done on another computer where the borders show color, shows white only. I have attempted to do a repair on publisher, which gave no help. Have attempted to uninstalled and reinstall Publisher without clearing the problem. Anyone have any ideas or suggestions? Look in the Accessibility Options in the control panel, display tab, disable "use high contrast." If that doesn't solve the issue, read the third FAQ here....

Trying to read XML file into dataset
Hello. Developing a web site in VS2005, SP1, VB, .NET 2.0, ASP.NET 2.0 on XP Pro, SP2. I eventually want to use a gridview table to view xml data, but right now i can't seem to get my xml data into a dataset so that i can use it. I have an XML file and can open it in IE. There is no XSD or XSL file to go with it. I can't seem to get the XML data into a dataset. I tried using the following code, but it just does nothing. It doesn't give an error. It just executes the code and does nothing. Dim dataSet As DataSet = New DataSet dataSet.ReadXml("...

[b]Can I download Excel data to a MS Access database?[/b]
I've built an Excel 2002 form that I want our internal customers to access from our intranet, and use. Once completed, they will send it to us as an e-mail attachment. I'd like to be able to open it, and somehow download the data from the form into an MS Access 2002 database I've built (so that we don't have to rekey it into the database). Is this possible or even feasible? Any and all help is appreciated. Thanks. :D --------- Message sent via www.excelforums.com Hi in Access check 'File - Import External data' -- Regards Frank Kabel Frankfurt, Germany "...

Excel Problem
I have a 23.8 meg excel 2000 spreadsheet set for manual calculation saved to my local hard drive. Every time I try to open it, it takes forver and sometimes never opens but I do not get any error messages, let me just tell you that I am running a P4, 1 GB memory, Office 2K with SP3, and nothing else running when I try to open it. As I said it is set for manual calculation, and it is cleared to not auto calculate when opening or closing. Any idea's as to why this is happening? -- Todd I don't know why you're having this problem but I would like to point something out for w...

SOAP Exception
Hi, In my C# code, I have defined a Map object which is sent as part of a request to a web service, here's an extract of the part of the code: - Map map = new Map(); map.item = new mapItem[4] { new mapItem(), new mapItem(), new mapItem(), new mapItem() }; ................. But when I submit the request containing the Map object, the compiler throws an error with the following message:- org.xml.sax.SAXException: No deserializer for {http://xml.apache.org/ xml-soap}...

Excel DNS query
Hello, Is there a way for an Excel function to query a DNS server? Thanks. Soundy Not that I know of, but you can turn on the macro recorder, use 'get external data' and tailor the resulting code into a user function of your own. E.g. I've used this to create a button to get MS-Access data from a query that has the same name as the sheet (tab) name. It saves me a lot of copy-paste actions. Bas Hartkamp <soundy@gmail.com> schreef in bericht news:1151940450.029823.127570@j8g2000cwa.googlegroups.com... > Hello, > > Is there a way for an Excel function ...