#1
|
|||
|
|||
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 |
#2
|
||||
|
||||
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] |
#3
|
|||
|
|||
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 |
#4
|
||||
|
||||
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] |
#5
|
|||
|
|||
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 |
#6
|
||||
|
||||
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] |
Tags |
convert, xml in ms word |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
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 |