Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 06-09-2015, 08:26 PM
macropod's Avatar
macropod macropod is offline VBA to save word user form value to xml Windows 7 64bit VBA to save word user form value to xml Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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
  #17  
Old 06-10-2015, 06:39 AM
Rose roon Rose roon is offline VBA to save word user form value to xml Windows 7 64bit VBA to save word user form value to xml Office 2007
Novice
VBA to save word user form value to xml
 
Join Date: Jun 2015
Posts: 28
Rose roon is on a distinguished road
Default

Hi Paul & Greg,

Thank you so much for your help.

I will try

Regards,
Rose
Reply With Quote
  #18  
Old 06-11-2015, 07:51 AM
Rose roon Rose roon is offline VBA to save word user form value to xml Windows 7 64bit VBA to save word user form value to xml Office 2007
Novice
VBA to save word user form value to xml
 
Join Date: Jun 2015
Posts: 28
Rose roon is on a distinguished road
Default

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







Reply With Quote
  #19  
Old 06-11-2015, 04:23 PM
macropod's Avatar
macropod macropod is offline VBA to save word user form value to xml Windows 7 64bit VBA to save word user form value to xml Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

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]
Reply With Quote
  #20  
Old 06-13-2015, 05:02 AM
Rose roon Rose roon is offline VBA to save word user form value to xml Windows 7 64bit VBA to save word user form value to xml Office 2007
Novice
VBA to save word user form value to xml
 
Join Date: Jun 2015
Posts: 28
Rose roon is on a distinguished road
Default

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
Reply With Quote
  #21  
Old 06-13-2015, 02:35 PM
macropod's Avatar
macropod macropod is offline VBA to save word user form value to xml Windows 7 64bit VBA to save word user form value to xml Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

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]
Reply With Quote
  #22  
Old 06-14-2015, 09:03 AM
Rose roon Rose roon is offline VBA to save word user form value to xml Windows 7 64bit VBA to save word user form value to xml Office 2007
Novice
VBA to save word user form value to xml
 
Join Date: Jun 2015
Posts: 28
Rose roon is on a distinguished road
Default

Thank you Paul

Regards,
Rose
Reply With Quote
  #23  
Old 06-22-2015, 11:43 PM
Rose roon Rose roon is offline VBA to save word user form value to xml Windows 7 64bit VBA to save word user form value to xml Office 2007
Novice
VBA to save word user form value to xml
 
Join Date: Jun 2015
Posts: 28
Rose roon is on a distinguished road
Default

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
Reply With Quote
  #24  
Old 06-23-2015, 02:37 AM
macropod's Avatar
macropod macropod is offline VBA to save word user form value to xml Windows 7 64bit VBA to save word user form value to xml Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

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]
Reply With Quote
  #25  
Old 06-23-2015, 03:28 AM
Rose roon Rose roon is offline VBA to save word user form value to xml Windows 7 64bit VBA to save word user form value to xml Office 2007
Novice
VBA to save word user form value to xml
 
Join Date: Jun 2015
Posts: 28
Rose roon is on a distinguished road
Default

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
Reply With Quote
  #26  
Old 06-23-2015, 04:35 AM
macropod's Avatar
macropod macropod is offline VBA to save word user form value to xml Windows 7 64bit VBA to save word user form value to xml Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

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]
Reply With Quote
Reply

Thread Tools
Display Modes


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
VBA to save word user form value to xml Force User to Save As lgillespie Word 6 09-09-2013 03:13 PM
VBA to save word user form value to xml User Form placasse47 Excel Programming 3 08-01-2012 05:57 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:20 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft