Page 1 of 1
Export To Word
Posted: Fri Jan 31, 2020 1:28 am
by TimStone
I hadn't looked at this previously but a client brought it to me today.
I create reports that are all text. They display fine in View mode, and the print without a problem.
When I save them to a file ( .doc ) or export using the Word icon in Preview, Word sees each page as a picture. As a result, it is impossible to edit the text in Word.
Surely I am doing something wrong here. What is it ? I'm using the latest FWH libraries and the latest Word included in Office 365.
Thanks.
Re: Export To Word
Posted: Fri Jan 31, 2020 7:56 am
by Massimo Linossi
The function exports the EMF image file to Word.
You can never edit the text.
Re: Export To Word
Posted: Fri Jan 31, 2020 5:26 pm
by TimStone
That seems of no value to me. Thus the data is not useable.
Is there a way to export that report to Word so it can be edited ?
Re: Export To Word
Posted: Fri Jan 31, 2020 6:29 pm
by MOISES
No, it's not possible in the current state.
You would either have to create a module to generate a Word file the way it is exported to Excel, or export it to plain text.
Re: Export To Word
Posted: Fri Jan 31, 2020 8:55 pm
by TimStone
I found a workaround. You can export it to a PDF, and then open that in Word which will convert it to editable text in the correct format.
We really shouldn't claim to have an export to word that just sends pictures which cannot be edited. That is not a functional export.
Re: Export To Word
Posted: Sat Feb 01, 2020 12:34 am
by Otto
Hello Tim,
Thank you. You have found a great solution.
It should be easy to open word and then save it as docx. I made a short test.
Best regards
Otto
Code: Select all
#Include "FiveWin.ch"
//--------------------------//
function Main()
local oWord
local oDoc
local cDocument := "c:\_mist\umsatz.pdf"
local cSaveAsFile := ""c:\_mist\umsatz.DOCX""
oWord := CREATEOBJECT( "Word.Application" )
oDoc := oWord:Documents:Open( cDocument )
oWord:Visible := .t.
cSaveAsFile := "c:\_mist\umsatz.DOCX"
#define wdFormatXMLDocument 12
oWord:ActiveDocument:SaveAs2( cSaveAsFile, wdFormatXMLDocument )
oDoc:Close( 0 )
? "ENDE"
Return nil
//----------------------------------------------------------------------------//
Re: Export To Word
Posted: Sat Feb 01, 2020 9:53 am
by Massimo Linossi
Otto,
the FWH preview works with EMF files, that are images. If you export them in PDF
the resulting file is not editable. What you are doing is with PDF files that you can edit
and for this reason Word can make the same. If you want to have a DOC or PDF file
that you can modify you must make this not in the preview function but before.
So you must change the report or print function.
Re: Export To Word
Posted: Sat Feb 01, 2020 10:15 am
by Otto
Hello Massimo,
Thank you.
For me, with the code, I posted it is working fine.
I changed
function ConvertToWordDoc( oPreview ).
First, I create in silent a PDF, and then I open and save it with WORD to Docx.
Best regards
Otto
Re: Export To Word
Posted: Sat Feb 01, 2020 8:25 pm
by TimStone
Massimo,
Using the latest version of FWH, I exported to a PDF. Of course it was saved. I did this from PREVIEW using the File Save option. Then I used Word to open the PDF. It is fully editable in Word. I made changes and saved it.
Perhaps something changed, but it is working this way. Once I reported it, from MY testing, Otto made his routine.
I will explore building in his option as an alternative to the Word Export button so we have a TRUE Word document. What we have now is of no value since Word can't do anything with it that a normal printer couldn't do directly.
Tim
Re: Export To Word
Posted: Sun Feb 02, 2020 11:33 am
by MOISES
I totally agree, we need a native Word export option. However, the proposed fix by Otto does not work with Office versions prior to 2007, and I do not know if it will work well with Office 365 and the reduced versions of Word that come by default on some computers.
Re: Export To Word
Posted: Thu Feb 06, 2020 8:53 pm
by James Bott
We really shouldn't claim to have an export to word that just sends pictures which cannot be edited. That is not a functional export.
There are times when you don't want users to edit a report. Actually, I would say most times.
If you allow users to edit reports, they can make them inaccurate. This is normally one of the reasons for using software--to prevent inaccuracies in manually created data and/or reports.
If the software generated reports are wrong and the users are fixing them, then the software generated reports should be fixed in the software instead.
If there are times when perhaps something like titles need to be changed for a special report, then I would suggest providing a drop-down list instead, or just a separate report.
James
Re: Export To Word
Posted: Thu Feb 06, 2020 11:15 pm
by TimStone
James,
In today's software market place, people like to do "mark ups" and notes on reports. We are not "editing" anything within the software. Instead, they are taking output and adding to it in individual situations.
In the case of one client, our system has many pages of "glossaries" or text templates. My client doesn't want to sit late at night in a cold and dark shop making changes. He wants to save that document, take it home, and make his modifications at his home computer. He reworks descriptions until he's happy with the result. THEN he takes the final printout of his work into the shop and makes the changes to these records within the software itself.
Fortunately, saving it as a PDF and then importing it into Word does work, and allows him to handle his specific needs.
Ti,