View Single Post
 
Old 06-09-2015, 08:26 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,373
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Another approach would be to write your metadata directly from the userform to a text file with an xml extension, using code along the lines of:
Code:
Dim StrXML As String, StrName As String
StrXML = "<metadata>" & vbCrLf
StrXML = StrXML & "<SystemInfo>" & Customer_Info.Text & "</SystemInfo>" & vbCrLf
StrXML = StrXML & vbTab & "<NumberOfRecords>" & Record_Count.Text & "</NumberOfRecords>" & vbCrLf
StrXML = StrXML & vbTab & vbTab & "<FileTransferHeader>" & vbCrLf
StrXML = StrXML & vbTab & vbTab & "<ProcessingDate>" & Format(Date, "YYYYMMDD") & "</ProcessingDate>" & vbCrLf
StrXML = StrXML & vbTab & vbTab & "<ProcessingTime>" & Format(Date, "hhmmss") & "</ProcessingTime>" & vbCrLf
StrXML = StrXML & vbTab & vbTab & "<FileName>" & ActiveDocument.Name & "</FileName>" & vbCrLf
StrXML = StrXML & vbTab & "</FileTransferHeader>" & vbCrLf & vbTab & "<RecordsInfo>" & vbCrLf
StrXML = StrXML & vbTab & vbTab & "<Name>" & Name.Text & "</Name>" & vbCrLf
StrXML = StrXML & vbTab & vbTab & "<Address>" & Address.Text & "</Address>" & vbCrLf
StrXML = StrXML & vbTab & vbTab & "<Author>" & ActiveDocument.BuiltInDocumentProperties(wdPropertyAuthor) & "</Author>" & vbCrLf
StrXML = StrXML & vbTab & "</RecordsInfo>" & vbCrLf & "</metadata>"
StrName = Split(ActiveDocument.FullName, ".")(0) & ".xml"
Open StrName For Output As #1
Print #1, StrXML
Close #1
The above code snippet assumes your userform has textboxes named:
Customer_Info
Record_Count
Name
Address
and that the document has been saved. The xml file is given the same name as the document it is obtained from and is saved to the same folder.

Although the text file is formatted with tabs so its structure resembles what you see when you view the xml in I.E., that isn't really necessary.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote