![]() |
|
#15
|
||||
|
||||
|
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 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] |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| User Form - Close Paragraphs | SonyaEnz | Word VBA | 4 | 06-05-2015 06:16 AM |
| User form | abdulgani | Excel | 0 | 12-15-2014 05:54 AM |
| how to save contents in textbox in VB2013 form into a Word document? | saltlakebuffalo | Word VBA | 6 | 12-10-2014 06:12 PM |
Force User to Save As
|
lgillespie | Word | 6 | 09-09-2013 03:13 PM |
User Form
|
placasse47 | Excel Programming | 3 | 08-01-2012 05:57 AM |