Welcome! Log In Create A New Profile

Advanced

Convert .doc to .docx

Posted by Frans 
Convert .doc to .docx
May 27, 2020 04:43PM
Hello to you all,

The WD integrated Wordprocessor is nice. But it only works with .docx files.
Because even now the majority of documents are in .doc format we need to integrate a doc to docx converter.

Does anyone have such a coverter or where to get/buy it?

Thanks in advance.
Regards Frans
Al
Re: Convert .doc to .docx
May 27, 2020 05:05PM
Hello Frans

I use the GemBox routines to manage MS Word documents and whenever it saves a document it has opened, it saves it in .docx format so it could be used as a file converter.

[www.gemboxsoftware.com]

However if the integrated word processor functions can open a .doc file, could you build a function using the FFile() commands to read a directory and loop though the .doc files just opening them and then doing a SaveAs to the .docx format.

The help has a section : Handling a Word Processing control by programming that might help you build a process

The OLE functions are also available and could do the same thing I think.


Regards
Al
Re: Convert .doc to .docx
May 27, 2020 05:33PM
Hello Al,

Thanks for your answer.
The wordprocessor control can't read .doc files. That is the problem. Otherwise it would be a wonderfull tool.
I searched for a long time in the help. No answer.
I will look at GemBox. Not to expensive and not cheap. 680 dollar.

Thanks again. It is a possibility.

Regards Frans
JP
Re: Convert .doc to .docx
May 27, 2020 05:36PM
Frans

If the machine on which you run your app has a copy of MS Word you could automate it; create an object of it, use that to open the DOCX, and resave as a DOC. This is one option.

JP
Ola
Re: Convert .doc to .docx
May 27, 2020 06:24PM
Hi Frans,

what version are you talking about?
Is the new version 25 still unable to open .DOC files?

best regards
Ola
Re: Convert .doc to .docx
May 28, 2020 11:19AM
Hello Ola,

No does not work in WD25.
When you try to open a .doc file then you get a message that you have to open the document in your own wordprocessor and save it as .docx and then open it in WD

Regards Frans
Re: Convert .doc to .docx
May 28, 2020 11:24AM
Hello JP,

Thanks for your answer. It is a possibility. I wil look at it.

I also have emailed PcSoft for a solution.
Otherwise the wordprocessor is almost useless.

Regards Frans
JP
Re: Convert .doc to .docx
May 28, 2020 11:45AM
Frans

Also check out the ActiveX solution from CoolUtils - [www.coolutils.com]
Al
Re: Convert .doc to .docx
May 28, 2020 02:15PM
Hello Frans

If you have MS Word available to act as a server, then MS Offiffice automation can be used to open and save the document.
I have a find and replace routine written for me by a friend that uses office automation but I haven't used it for a few years because I switched to GemBox.

PROCEDURE DocFindAndReplace(LocalDocName = "")
//08/12/14
//LDocDirName a full path name of the document as C:\foldername\filename

LOkToFindReplace is boolean = False

	MyWordObject is dynamic Automation object //object OLE Dynamic
	
	IF MyWordObject <> Null THEN
		MyWordObject>>Visible = OLETrue
		MyWordObject>>Quit()
	END
	MyWordObject=GetActiveObject("Word.Application")
	IF MyWordObject=Null THEN
		// check if word is open 
		WHEN EXCEPTION IN
			MyWordObject = new object OLE "Word.Application"
		DO 
			Info("MS Word is not installed on this computer.  The find and replace function cannot complete")
			LOkToFindReplace = False
			GRunFindReplaceAgain = True
			delete MyWordObject
		END //exception
	END
	IF LOkToFindReplace = True
		MyWordObject>>Visible=True
		MyWordObject>>Application>>Visible=True
		MyWordObject>>Documents>>Open(LocalDocName,False,False)

		//find and replace routine
		 		
		MyWordObject>>Quit(-1)
		delete MyWordObject 			
	END //


My skills in Office Automation are zero so I can't help with getting the SaveAs part working.
If you could create a macro in MS Word to SaveAs, it should reveal the correct process.

There is some general (not Windev) work on web
Here is one example I found
[stackoverflow.com]

Regards
Al
Re: Answer PcSoft
May 28, 2020 05:50PM
Hello Al,

Thanks for your answer . Wow!

I also send a question to PcSoft and got the following answer:

Only the docx format is supported at the moment. A suggestion has been registered to add this feature in a future release.
Command line converters must exist, it's a possible workaround.

Regards Frans
Ola
Re: Convert .doc to .docx
May 28, 2020 08:18PM
Hi all

Based on all the above, I suppose I can safely assume, that also WordStar and WordPerfect files are not supportedspinning smiley sticking its tongue out
Maybe I'll just pass version 25...

Best regards
Ola
Re: Convert .doc to .docx
May 29, 2020 09:37AM
Hi to all of you.

Thanks to AI and to PCsoft example of "WD Controlling Word", I make the following piece of code, which works like a charm:

PROCEDURE SaveAsDocx(LocalDocName is string)

MyWordObject is object OLE dynamic

IF MyWordObject <> Null THEN
	MyWordObject>>Visible = OLETrue
	MyWordObject>>Quit()
END
MyWordObject = GetActiveObject("Word.Application")
IF MyWordObject = Null THEN
	// check if word is open 
	WHEN EXCEPTION IN
		MyWordObject = new object OLE "Word.Application"
	DO
		Info("MS Word is not installed on this computer.")
		delete MyWordObject
		RETURN
	END
END
OpenWord(LocalDocName)
SaveAsWord(LocalDocName)
CloseWord()


INTERNAL PROCEDURE OpenWord(DocumentName)
	WHEN EXCEPTION IN
		MyWordObject>>Documents>>Open(DocumentName)
	DO
		Error("Unable to Open the document.", ExceptionInfo())
		RETURN
	END
	MyWordObject>>Visible = True
END


INTERNAL PROCEDURE SaveAsWord(DocumentName)
	NewDocName is string = Replace(DocumentName, ".doc", ".docx", IgnoreCase)
	WHEN EXCEPTION IN
		MyWordObject>>ActiveDocument>>SaveAs(NewDocName, 16)
	DO
		Error("Unable to Save as the document.", ExceptionInfo())
		CloseWord()
	END
	LocalDocName = NewDocName
END


INTERNAL PROCEDURE CloseWord()
	IF MyWordObject <> Null THEN
		WHEN EXCEPTION IN
			MyWordObject>>Quit(False, False, False)
		DO
			Error("Unable to Close the document.", ExceptionInfo())
		END
		Multitask(-30)
		delete MyWordObject
	END
END

The LocalDocName is the .doc file you want to convert to .docx

Best Regards

Vassilis Boutsikas
Al
Re: Convert .doc to .docx
May 29, 2020 09:56AM
Hello Vassilis

Great work - thank you.


Regards
Al
Re: Convert .doc to .docx
May 29, 2020 10:14AM
Hello Vassilis,

Top. Thanks.
Regards Frans
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: