Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error - Object Variable or With Block Variable not set

Status
Not open for further replies.

Maggie24

IS-IT--Management
Jun 29, 2004
36
IE
Hi all,

I am currently trying to step through code for a Batch Job which moves files from one folder to another.

I am getting the error "Object Variable or With Block Variable not set" on the following line:

Set oTagAttributes = oNodeBirthDetails.Attributes

If anyone has experienced this error with Batch Jobs please let me know what ye did as I am totally stumped,The full code for this part is as follows:

Dim oNodeListBirthNot, oNodeListPerson, oNodeListPOB, oNodeListPDeath As MSXML2.IXMLDOMNodeList
Dim oNodeBirthDetails, oNodeChild, oNodeMother, oNodeFather As MSXML2.IXMLDOMNode
Dim oNodeGeneral, oNodePersonName, oNodeAddress, oNodePrevPregDetails As MSXML2.IXMLDOMNode
Dim oNodePDeath, oNodeHospital, oNodePlaceOfBirth As MSXML2.IXMLDOMNode
Dim oTagAttributes As MSXML2.IXMLDOMNamedNodeMap

Dim oXMLElement As MSXML2.IXMLDOMElement
Dim oAttribute As MSXML2.IXMLDOMAttribute

Set oNodeListPerson = oNotificationDoc.getElementsByTagName(g_cXML_Person)
Set oNodeListPOB = oNotificationDoc.getElementsByTagName(g_cXML_PlaceOfBirth)
Set oNodeListPDeath = oNotificationDoc.getElementsByTagName(g_cXML_PerinatalDeath)
Set oNodeListBirthNot = oNotificationDoc.getElementsByTagName(g_cXML_BirthRegistration)

Set oNodePlaceOfBirth = oNodeListPOB.Item(0)
Set oNodeChild = oNodeListPerson.Item(0)
Set oNodeMother = oNodeListPerson.Item(1)
Set oNodeFather = oNodeListPerson.Item(2)
Set oNodePDeath = oNodeListPDeath.Item(0)
Set oNodeBirthDetails = oNodeListBirthNot.Item(0)

Dim dictChildsDetails As Scripting.Dictionary
Set dictChildsDetails = CreateObject("Scripting.Dictionary")
Dim dictMothersDetails As Scripting.Dictionary
Set dictMothersDetails = CreateObject("Scripting.Dictionary")
Dim dictFathersDetails As Scripting.Dictionary
Set dictFathersDetails = CreateObject("Scripting.Dictionary")
Dim dictGenDetails As Scripting.Dictionary
Set dictGenDetails = CreateObject("Scripting.Dictionary")
Dim dictPeriNatalDetails As Scripting.Dictionary
Set dictPeriNatalDetails = CreateObject("Scripting.Dictionary")

'**************Doc Attributes***************
Set oNodeGeneral = oNotificationDoc.getElementsByTagName(g_cXML_MessageSourceID)
Set oXMLElement = oNodeGeneral(0)
sMessageSourceID = oXMLElement.nodeTypedValue

Set oNodeGeneral = oNotificationDoc.getElementsByTagName(g_cXML_MessageSource)
Set oXMLElement = oNodeGeneral(0)
sMessageSource = oXMLElement.nodeTypedValue

'**************Birth Attributes***************
Set oTagAttributes = oNodeBirthDetails.Attributes

sAction = IIf(oTagAttributes.getNamedItem(g_cXML_BirthRegistration_Action).nodeTypedValue = vbNullString, vbNullString, oTagAttributes.getNamedItem(g_cXML_BirthRegistration_Action).nodeTypedValue)
iSourceRef = IIf(oTagAttributes.getNamedItem(g_cXML_BirthRegistration_SourceRef).nodeTypedValue = vbNullString, -99, oTagAttributes.getNamedItem(g_cXML_BirthRegistration_SourceRef).nodeTypedValue)



If anyone has experienced this error with Batch Jobs please let me know what ye did as I am totally stumped,

Thanks a million,

Maggi



"Work is the curse of the drinking classes
 
Maggi,

Let's look at this line of code:
Dim oNodeBirthDetails, oNodeChild, oNodeMother,
oNodeFather As MSXML2.IXMLDOMNode

This will dimension oNodeBirthDetails, oNodeChild, and oNodeMother as variants and oNodeFather As MSXML2.IXMLDOMNode.

I don't believe a variant has attributs property or function which explains the error

To dimension all those variables as MSXML2.IXMLDOMNode
you need to do one of the following two things:

(All 1 line [line continuations _ may be used])

Dim oNodeBirthDetails As MSXML2.IXMLDOMNode, oNodeChild As MSXML2.IXMLDOMNode, oNodeMother As MSXML2.IXMLDOMNode, oNodeFather As MSXML2.IXMLDOMNode


OR

Dim oNodeBirthDetails As MSXML2.IXMLDOMNode
dim oNodeChild As MSXML2.IXMLDOMNode
dim oNodeMother As MSXML2.IXMLDOMNode
dim oNodeFather As MSXML2.IXMLDOMNode

-Sean
 
Hi Sean,

I have tried that and unfortunately no joy.

The code works on another machine, its just when i have copied down to my machine - it is not working, so maybe i am missing a reference or something??

Any help would be greatly appreciated!!

Maggi

"Work is the curse of the drinking classes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top