Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-25-2012, 05:19 PM
FelipeGar FelipeGar is offline How can convert MSOffice .xml files to .doc or .pdf? Windows 7 64bit How can convert MSOffice .xml files to .doc or .pdf? Office 2007
Novice
How can convert MSOffice .xml files to .doc or .pdf?
 
Join Date: Jan 2012
Posts: 2
FelipeGar is on a distinguished road
Default How can convert MSOffice .xml files to .doc or .pdf?

Hallo:

I've lots of files generated with MSOffice in .xml format.

I want to convert them to .doc or .pdf.

What I do:

file.xml -->import in MSOffice and export to-->file.doc

The problem is that I have to open MSOffice to convert the files and I want to do it from command line.

Is there any way to convert MSOffice .xml files to .doc or .pdf from command line?

Thanks
Reply With Quote
  #2  
Old 01-26-2012, 06:46 PM
macropod's Avatar
macropod macropod is online now How can convert MSOffice .xml files to .doc or .pdf? Windows 7 64bit How can convert MSOffice .xml files to .doc or .pdf? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

hi Felipe,

What is your objection to using Word? Whatever approach you take, you're going to have to start some application to do the conversion.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 01-27-2012, 12:53 AM
FelipeGar FelipeGar is offline How can convert MSOffice .xml files to .doc or .pdf? Windows 7 64bit How can convert MSOffice .xml files to .doc or .pdf? Office 2007
Novice
How can convert MSOffice .xml files to .doc or .pdf?
 
Join Date: Jan 2012
Posts: 2
FelipeGar is on a distinguished road
Default

No, I have no problem to use MSOffice.

The problem is that we have thousand files and need to convert them to .pdf.
So I need a conmmand line converter.
Do you know if Word accept command line parameters for automatic conversion?

Or another option can be a Macro.
Can any tell me how can I create a macro for converting the .xml file?

What I try:
-Run "Winword.exe filename.xml /mexportToPDF"

How can I create the "exportToPDF" macro wich is called when winword starts and the only thing it does is to save the "filename.xml" to "filename.pdf" and closes the file "filename.xml"?

Regards
Reply With Quote
  #4  
Old 01-27-2012, 01:21 AM
macropod's Avatar
macropod macropod is online now How can convert MSOffice .xml files to .doc or .pdf? Windows 7 64bit How can convert MSOffice .xml files to .doc or .pdf? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Hi Felipe,

A Word macro can be used to process thousands of files, without the user having to do any more than select the folder to process. I have posted a number of such macros here.

Assuming the xml files are in a format Word can open, you can use code like:
Code:
Sub XML2PDF()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdDoc As Document
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.xml", vbNormal)
While strFile <> ""
  Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
  wdDoc.SaveAs2 FileName:=strFolder & "\" & Split(strFile, ".xml")(0) & ".pdf", Fileformat:=wdFormatPDF, AddToRecentFiles:=False
  wdDoc.Close
  strFile = Dir()
Wend
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub
 
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 04-01-2015, 03:13 AM
Attamjot Attamjot is offline How can convert MSOffice .xml files to .doc or .pdf? Windows 7 32bit How can convert MSOffice .xml files to .doc or .pdf? Office 2010 32bit
Novice
 
Join Date: Apr 2015
Posts: 1
Attamjot is on a distinguished road
Default

Hello ,
Actually the macro works fine but the issue is ,it is trying to open the info path form with .XML extension to Microsoft word due to which only the data is getting fetched the order/look and feel is not getting fetched .Only the data is getting converted to the PDF format.
Request you to please make some change to the macro so that the proper structure gets fetched and gets converted to PDF format .
Thanks
Attamjot
Reply With Quote
  #6  
Old 06-05-2015, 04:51 AM
macropod's Avatar
macropod macropod is online now How can convert MSOffice .xml files to .doc or .pdf? Windows 7 64bit How can convert MSOffice .xml files to .doc or .pdf? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Hi Attamjot ,

I've been away for 3 1/2 months, hence the delay in replying.

There is no 'proper' format for an XML file.

What you're asking for would require a lot of extra coding as XML files are mere text files with no formatting at all. You can see that by changing such a file's extension to .txt and opening it with notepad.

The XML structure you see in apps like I.E. appears that way because the programmers have written the code to display such files that way.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
convert, xml in ms word

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can convert MSOffice .xml files to .doc or .pdf? convert multiple csv files to multiple excel files mit Excel 1 06-14-2011 10:15 AM
Bulk convert Powerpoint XML files to PPT or PPTX RileyT PowerPoint 0 11-21-2010 04:16 PM
Convert JML files Lundberg Word 5 09-11-2010 11:05 AM
can I index or convert old msworks files to be searchable? elijah Word 0 02-10-2010 01:57 PM
How 2 retain MSOffice "Upgraded" on full restore misterbobthetomato Office 0 02-04-2007 11:08 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:51 AM.


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