![]() |
#16
|
||||
|
||||
![]()
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] |
#17
|
|||
|
|||
![]()
Hi Paul & Greg,
Thank you so much for your help. I will try Regards, Rose |
#18
|
|||
|
|||
![]()
Hi Paul,
When I check custom xml, it looks like this <?xml version="1.0" encoding="UTF-8" standalone="true"?> <Properties xmlns:vt="http://schemas.openxmlformats.org/of...docPropsVTypes" xmlns="http://schemas.openxmlformats.org/of...tom-properties"><property name="userName" pid="2" fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"><vt:lpwstr>mma</vt:lpwstr></property><property name="processingDate" pid="3" fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"><vt:lpwstr>11-06-2015</vt:lpwstr></property><property name="processingTime" pid="4" fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"><vt:lpwstr>20:11:39</vt:lpwstr></property><property name="fileName" pid="5" fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"><vt:lpwstr>macro.docx</vt:lpwstr></property><property name="author" pid="6" fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"><vt:lpwstr>Mary</vt:lpwstr></property><property name="redactionRequired" pid="7" fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"><vt:lpwstr>yes</vt:lpwstr></property></Properties> is it possible to format as required please let me know thanks & Regards, Rose |
#19
|
||||
|
||||
![]()
What you've posted doesn't seem to have anything to do with what's been discussed so far and, as I have said previously, xml code is just plain text without any particular 'format' for viewing purposes. That said, it also appears the code you posted is mal-formed, as it doesn't display in I.E.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#20
|
|||
|
|||
![]()
Hi Paul,
Noted , Thanks. I managed to save the text file with an xml extension. xml declaration is <?xml version="1.0"?> it suppose to be <?xml version="1.0" encoding="UTF-8" standalone="yes"?> Please advice Appreciate your help Thanks & Regards, Rose |
#21
|
||||
|
||||
![]()
You could change:
StrXML = "<metadata>" & vbCrLf to: StrXML = "<?xml version="1.0" encoding="UTF-8" standalone="yes"?>" & vbCrLf & "<metadata>" & vbCrLf
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#22
|
|||
|
|||
![]()
Thank you Paul
![]() Regards, Rose |
#23
|
|||
|
|||
![]()
Hi Paul,
Need your help, before save the value as xml is it possible to validate against the Active directory account? any sample macro code for it? Thanks & Regards Rose |
#24
|
||||
|
||||
![]()
Without knowing exactly what your validation requirements are, and how you intend them to be incorporated into the output (if, indeed, that's required), it's impossible to code for them.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#25
|
|||
|
|||
![]()
Hi Paul,
Thanks for your reply Sorry, need to prompt the screen to enter user name and password from user. This username and passwords listed and match with Active directory credential allow to save as xml or exit. Hope understand Thanks & Regards, Rose |
#26
|
||||
|
||||
![]()
Those issues have nothing to do with the code I've provided. Rather, they suggest you need to equip your userform with textboxes for the username & password inputs and do the validation there. A web search should turn up some sample code you could use/adapt.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
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 |
![]() |
lgillespie | Word | 6 | 09-09-2013 03:13 PM |
![]() |
placasse47 | Excel Programming | 3 | 08-01-2012 05:57 AM |