I'm have a script that will list the XML's and did not produce a PDf.
getting the list of Pdf's works,
but now I need to get policy number from the xml file.
InStr is returning the pos number but I would like the text.
here is the code.
Set FileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='D:\to_print'} Where " _
& "ResultClass = CIM_DataFile")
For Each objFile In FileList
' Wscript.echo objFile.Drive & objFile.Path & objFile.FileName
If objFile.Extension = "xml" Then
strNewName = objFile.Drive & objFile.Path & objFile.FileName & "." & "pdf"
if objFSO.FileExists(strNewName) then
writeflag = "N"
else
strSearchName = objFile.Drive & objFile.Path & objFile.FileName & "." & "xml"
strMatch="<PolicyRef>" 'This is the string to search for.
if InStr(1,objFSO.OpenTextFile (strSearchName).ReadAll,strMatch,vbTextCompare) > 0 Then
' what code do I need here???? to get the line with the policyref number on it
strPolicy = InStr???
End If
strContents = strSearchName & " - " & strPolicy & vbCrLf
objFile2.Write strContents
strContents = ""
writeflag = "Y"
End If
End If
Next
getting the list of Pdf's works,
but now I need to get policy number from the xml file.
InStr is returning the pos number but I would like the text.
here is the code.
Set FileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='D:\to_print'} Where " _
& "ResultClass = CIM_DataFile")
For Each objFile In FileList
' Wscript.echo objFile.Drive & objFile.Path & objFile.FileName
If objFile.Extension = "xml" Then
strNewName = objFile.Drive & objFile.Path & objFile.FileName & "." & "pdf"
if objFSO.FileExists(strNewName) then
writeflag = "N"
else
strSearchName = objFile.Drive & objFile.Path & objFile.FileName & "." & "xml"
strMatch="<PolicyRef>" 'This is the string to search for.
if InStr(1,objFSO.OpenTextFile (strSearchName).ReadAll,strMatch,vbTextCompare) > 0 Then
' what code do I need here???? to get the line with the policyref number on it
strPolicy = InStr???
End If
strContents = strSearchName & " - " & strPolicy & vbCrLf
objFile2.Write strContents
strContents = ""
writeflag = "Y"
End If
End If
Next