From: Bob Barrows on 2 Apr 2010 11:46 Does this folder exist? "C:\Documents and Settings\U39012\Desktop\test\dita" That's what it's looking for. If not, create it and put the dita files there. Huber57 wrote: > Bob, > Here is the error I get now. > > Script: C:\Documents and Settigns\U39012\Desktop\filepath.vbs > Line: 6 > Char: 1 > Error: Path not found > Code: 800A004C > Source: Microsof VBScript runtime error > > I looked online and some of the discussion forums attribute this to > permissions. But, I am the admin of my computer and it is on my > desktop. > > dim fso,fldr,fil,xmldoc,nodes,kwnode,itnode,xl,wb,ws,kwrow,itrow > dim pathtofiles > 'replace with your path > pathtofiles="C:\Documents and Settings\U39012\Desktop\test" > set fso=createobject("scripting.filesystemobject") > set fldr=fso.getfolder(pathtofiles & "\dita") > set xmldoc=createobject("msxml2.domdocument") > set xl=createobject("excel.application") > xl.workbooks.add > set wb=xl.workbooks(1) > set ws=wb.sheets(1) > ws.name="dita_values" > kwrow=1 > itrow=1 > ws.cells(kwrow,1).FormulaR1C1="Keywords" > ws.cells(itrow,2).FormulaR1C1="Index Terms" > ws.range("A1:B1").font.bold=true > 'wscript.quit > kwrow=2 > itrow=2 > for each fil in fldr.files > xmldoc.load fil.path > set nodes = nothing > set nodes = xmldoc.selectnodes("//keyword") > if not nodes is nothing then > for each kwnode in nodes > ws.cells(kwrow,1).FormulaR1C1=kwnode.text > kwrow=kwrow+1 > next > else > msgbox "no nodes were found" > end if > set nodes = nothing > set nodes = xmldoc.selectnodes("//indexterm") > if not nodes is nothing then > for each itnode in nodes > ws.cells(itrow,2).FormulaR1C1=itnode.text > itrow=itrow+1 > next > end if > next > wb.saveas pathtofiles & "\keyword_indexterms.xls" > xl.quit > > "Bob Barrows" wrote: > >> Huber57 wrote: >>> Bob, >>> >>> I appreciate your patience with me. Here is the code: >>> >>> dim fso,fldr,fil,xmldoc,nodes, kwnode,itnode, xl,wb,ws,kwrow,itrow >>> dim pathtofiles >>> 'replace with your path >>> pathtofiles="C:\test" >>> set fso=createobject("scripting.filesystemobject") >>> set fldr=fso.getfolder(pathtofiles & "\dita") >>> set xmldoc=createobject("msxml2.domdocument") >>> set xl=createobject("excel.application") >>> xl.workbooks.add >>> set wb=xl.workbooks(1) >>> set ws=wb.sheets(1) >>> ws.name="dita_values" >>> kwrow=1 >>> itrow=1 ws.cells(kwrow,1).FormulaR1C1="Keywords" <=== >> >> Two lines got combined into one somehow. These should read: >> >> itrow=1 >> ws.cells(kwrow,1).FormulaR1C1="Keywords" >> >> Check the rest of the code carefully for similar problems. I just >> did a quick scan of the rest of what you posted and found nothing >> that stands out, but I'm only human. :-) >> >> -- >> Microsoft MVP - ASP/ASP.NET - 2004-2007 >> Please reply to the newsgroup. This email account is my spam trap so >> I don't check it very often. If you must reply off-line, then remove >> the "NO SPAM" >> >> >> . -- Microsoft MVP - ASP/ASP.NET - 2004-2007 Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM"
From: Huber57 on 2 Apr 2010 13:13 We are on a path toward victory! I created the dita folder and the script ran. The script created the .xls file along with the headers "Keywords" and "Index Terms" in A1 and B1 (In Sheet1) respectively. Unfortunately, it did not strip any of the key words or index terms out of the dita files and place them in the spreadsheet. Sincerely, Doug "Bob Barrows" wrote: > Does this folder exist? > "C:\Documents and Settings\U39012\Desktop\test\dita" > > That's what it's looking for. If not, create it and put the dita files > there. > > Huber57 wrote: > > Bob, > > Here is the error I get now. > > > > Script: C:\Documents and Settigns\U39012\Desktop\filepath.vbs > > Line: 6 > > Char: 1 > > Error: Path not found > > Code: 800A004C > > Source: Microsof VBScript runtime error > > > > I looked online and some of the discussion forums attribute this to > > permissions. But, I am the admin of my computer and it is on my > > desktop. > > > > dim fso,fldr,fil,xmldoc,nodes,kwnode,itnode,xl,wb,ws,kwrow,itrow > > dim pathtofiles > > 'replace with your path > > pathtofiles="C:\Documents and Settings\U39012\Desktop\test" > > set fso=createobject("scripting.filesystemobject") > > set fldr=fso.getfolder(pathtofiles & "\dita") > > set xmldoc=createobject("msxml2.domdocument") > > set xl=createobject("excel.application") > > xl.workbooks.add > > set wb=xl.workbooks(1) > > set ws=wb.sheets(1) > > ws.name="dita_values" > > kwrow=1 > > itrow=1 > > ws.cells(kwrow,1).FormulaR1C1="Keywords" > > ws.cells(itrow,2).FormulaR1C1="Index Terms" > > ws.range("A1:B1").font.bold=true > > 'wscript.quit > > kwrow=2 > > itrow=2 > > for each fil in fldr.files > > xmldoc.load fil.path > > set nodes = nothing > > set nodes = xmldoc.selectnodes("//keyword") > > if not nodes is nothing then > > for each kwnode in nodes > > ws.cells(kwrow,1).FormulaR1C1=kwnode.text > > kwrow=kwrow+1 > > next > > else > > msgbox "no nodes were found" > > end if > > set nodes = nothing > > set nodes = xmldoc.selectnodes("//indexterm") > > if not nodes is nothing then > > for each itnode in nodes > > ws.cells(itrow,2).FormulaR1C1=itnode.text > > itrow=itrow+1 > > next > > end if > > next > > wb.saveas pathtofiles & "\keyword_indexterms.xls" > > xl.quit > > > > "Bob Barrows" wrote: > > > >> Huber57 wrote: > >>> Bob, > >>> > >>> I appreciate your patience with me. Here is the code: > >>> > >>> dim fso,fldr,fil,xmldoc,nodes, kwnode,itnode, xl,wb,ws,kwrow,itrow > >>> dim pathtofiles > >>> 'replace with your path > >>> pathtofiles="C:\test" > >>> set fso=createobject("scripting.filesystemobject") > >>> set fldr=fso.getfolder(pathtofiles & "\dita") > >>> set xmldoc=createobject("msxml2.domdocument") > >>> set xl=createobject("excel.application") > >>> xl.workbooks.add > >>> set wb=xl.workbooks(1) > >>> set ws=wb.sheets(1) > >>> ws.name="dita_values" > >>> kwrow=1 > >>> itrow=1 ws.cells(kwrow,1).FormulaR1C1="Keywords" <=== > >> > >> Two lines got combined into one somehow. These should read: > >> > >> itrow=1 > >> ws.cells(kwrow,1).FormulaR1C1="Keywords" > >> > >> Check the rest of the code carefully for similar problems. I just > >> did a quick scan of the rest of what you posted and found nothing > >> that stands out, but I'm only human. :-) > >> > >> -- > >> Microsoft MVP - ASP/ASP.NET - 2004-2007 > >> Please reply to the newsgroup. This email account is my spam trap so > >> I don't check it very often. If you must reply off-line, then remove > >> the "NO SPAM" > >> > >> > >> . > > -- > Microsoft MVP - ASP/ASP.NET - 2004-2007 > Please reply to the newsgroup. This email account is my spam trap so I > don't check it very often. If you must reply off-line, then remove the > "NO SPAM" > > > . >
From: Bob Barrows on 2 Apr 2010 13:22 XML is case sensitive. If the structure you provided me is not really the structure in your files, then nothing will be found. For example, if the tags are named <Keywords> instead of <keywords>, then the script will not find them. Huber57 wrote: > We are on a path toward victory! I created the dita folder and the > script ran. The script created the .xls file along with the headers > "Keywords" and "Index Terms" in A1 and B1 (In Sheet1) respectively. > Unfortunately, it did not strip any of the key words or index terms > out of the dita files and place them in the spreadsheet. > -- Microsoft MVP - ASP/ASP.NET - 2004-2007 Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM"
From: Huber57 on 2 Apr 2010 14:19 Bob, I checked the files and they are all lowercase. I did notice one line of code: set nodes = xmldoc.selectnodes("//indexterm") I am not exactly sure what this is but the only opening/closing tag for the section is <keywords> and then </keywords>. Within these are lots of <keyword>test</keyword and <indexterm>another test</indexterm>. But there is no: <indexterms> and then </indexterms>. Does selectnodes refert to the <keywords></keywords> or the <keyword></keyword> tags? Regardless, still no output in the spreadsheeet. I do appreciate your help. "Bob Barrows" wrote: > XML is case sensitive. If the structure you provided me is not really the > structure in your files, then nothing will be found. For example, if the > tags are named <Keywords> instead of <keywords>, then the script will not > find them. > > Huber57 wrote: > > We are on a path toward victory! I created the dita folder and the > > script ran. The script created the .xls file along with the headers > > "Keywords" and "Index Terms" in A1 and B1 (In Sheet1) respectively. > > Unfortunately, it did not strip any of the key words or index terms > > out of the dita files and place them in the spreadsheet. > > > > > -- > Microsoft MVP - ASP/ASP.NET - 2004-2007 > Please reply to the newsgroup. This email account is my spam trap so I > don't check it very often. If you must reply off-line, then remove the > "NO SPAM" > > > . >
From: ekkehard.horner on 2 Apr 2010 15:12
I did some tests with Bob's code and sample files from the DITA Open Toolkit. One problem with the files is their refering to external DTDs; Bob's code should have included a test for parseErrors. I'm fairly confident that setting suitable properties on the xmldoc set xmldoc=createobject("msxml2.domdocument") ' ---- adds xmldoc.setProperty "SelectionLanguage", "XPath" xmldoc.async = False xmldoc.resolveExternals = False xmldoc.validateOnParse = False ' ---- set xl=createobject("excel.application") will help. The XPath expressions are valid for the DITA-OT samples. |