nhmabv
04-09-2012, 08:27 PM
I need to insert about 10 or so field values in an XML file.
I know that VB has support for setting values in an XML file which I want to use. I have been searching the internet and trying sample codes, but none of them work, I either encounter some error or I just cant figure how to adapt the code to my need. If someone can give me actual code to set one or two fields in the actual file , I could figure out the rest:
=======================================================
Lets say this is the contents of C:\abc\myfile.xml
<?xml version="1.0" encoding="UTF-8"?>
<Report version="4">
<ReportGUID></ReportGUID>
<ReportPID></ReportPID>
<ClientData>
<prop name="CFName1" type="0"></prop>
<prop name="CLName1" type="0"></prop>
<prop name="CFName2" type="0"></prop>
<prop name="CLName2" type="0"></prop>
<prop name="CHomePhone" type="0">NA</prop>
<prop name="CWorkPhone" type="0"></prop>
<prop name="CAddress" type="0">NA</prop>
<prop name="CCity" type="5">NA</prop>
<prop name="CZip" type="4">NA</prop>
<prop name="CEmail" type="0">NA</prop>
<prop name="CGuid" type="0">ClNoSheets04-07-201216:52:54</prop>
<prop name="ClientHMAPre" type="9">0</prop>
<prop name="CCountry" type="8">USA</prop>
<prop name="CState" type="7">Ca</prop>
</ClientData>
<ReportInfo>
<prop name="RIInspector" type="0">Mike Nolting</prop>
<prop name="RIInspectorCo" type="0">Pa Insp., Inc. dba xxxyxxx</prop>
<prop name="RIInspectorContact" type="0">1 Felipe Road Suite 1 Ho, VA 99023</prop>
<prop name="RICounty" type="6">Alameda</prop>
<prop name="RIInspector" type="0">Mike j</prop>
<prop name="RIInspectorCo" type="0">Pa., Inc. dba xxxx</prop>
<prop name="RIInspectorContact" type="0">17 lipe Road Suite 1 Hol, VA 98023</prop>
<prop name="RIAddress1" type="0"></prop>
<prop name="RICity" type="5"></prop>
<prop name="RIZip" type="4"></prop>
<prop name="RIReportNumber" type="0"></prop>
<prop name="RIDate" type="2"></prop>
<prop name="RIStartTime" type="3"></prop>
<prop name="RIState" type="7">Ca</prop>
<Person>
<PFName></PFName>
<PLName></PLName>
<PCompany></PCompany>
<PEmail></PEmail>
<PMobilePhone></PMobilePhone>
<PGuid></PGuid>
</Person>
</ReportInfo>
=======================================================
How do I set the value for CFName1 to "Bob" and how to I set the value for RIcity to "Hayward"?
Thanks
I am using Word VBA in Office 2003
I know that VB has support for setting values in an XML file which I want to use. I have been searching the internet and trying sample codes, but none of them work, I either encounter some error or I just cant figure how to adapt the code to my need. If someone can give me actual code to set one or two fields in the actual file , I could figure out the rest:
=======================================================
Lets say this is the contents of C:\abc\myfile.xml
<?xml version="1.0" encoding="UTF-8"?>
<Report version="4">
<ReportGUID></ReportGUID>
<ReportPID></ReportPID>
<ClientData>
<prop name="CFName1" type="0"></prop>
<prop name="CLName1" type="0"></prop>
<prop name="CFName2" type="0"></prop>
<prop name="CLName2" type="0"></prop>
<prop name="CHomePhone" type="0">NA</prop>
<prop name="CWorkPhone" type="0"></prop>
<prop name="CAddress" type="0">NA</prop>
<prop name="CCity" type="5">NA</prop>
<prop name="CZip" type="4">NA</prop>
<prop name="CEmail" type="0">NA</prop>
<prop name="CGuid" type="0">ClNoSheets04-07-201216:52:54</prop>
<prop name="ClientHMAPre" type="9">0</prop>
<prop name="CCountry" type="8">USA</prop>
<prop name="CState" type="7">Ca</prop>
</ClientData>
<ReportInfo>
<prop name="RIInspector" type="0">Mike Nolting</prop>
<prop name="RIInspectorCo" type="0">Pa Insp., Inc. dba xxxyxxx</prop>
<prop name="RIInspectorContact" type="0">1 Felipe Road Suite 1 Ho, VA 99023</prop>
<prop name="RICounty" type="6">Alameda</prop>
<prop name="RIInspector" type="0">Mike j</prop>
<prop name="RIInspectorCo" type="0">Pa., Inc. dba xxxx</prop>
<prop name="RIInspectorContact" type="0">17 lipe Road Suite 1 Hol, VA 98023</prop>
<prop name="RIAddress1" type="0"></prop>
<prop name="RICity" type="5"></prop>
<prop name="RIZip" type="4"></prop>
<prop name="RIReportNumber" type="0"></prop>
<prop name="RIDate" type="2"></prop>
<prop name="RIStartTime" type="3"></prop>
<prop name="RIState" type="7">Ca</prop>
<Person>
<PFName></PFName>
<PLName></PLName>
<PCompany></PCompany>
<PEmail></PEmail>
<PMobilePhone></PMobilePhone>
<PGuid></PGuid>
</Person>
</ReportInfo>
=======================================================
How do I set the value for CFName1 to "Bob" and how to I set the value for RIcity to "Hayward"?
Thanks
I am using Word VBA in Office 2003