Opening Word Doc files and Save them as PDF (Desktop Only)
Hello friends. This is my small contribution to this great forum and it's my way of saying "thank you" for all the great help you have all given me.
FINALLY! You can now open Word Doc files and load them into your project (for Desktop only).
Well... the method I use basically uses Agraham's Pretty Printing Library to create a Richtextbox in your project, then it uses D2R.exe, a very small program I created (using Visual Basic 6), to literally convert the .doc file into a .rtf file. You can then open your .rtf file using the richtextbox.LoadFile(AppPath & "\file.rtf") command from the Pretty Printing Library.
I use a Shell command to invoke D2R.exe to convert the .doc file. Sample:
Or, if you use the Threading Library:
REQUIREMENTS:
You must have Microsoft Word installed. You also need CutePDF Writer if you want to save your richtext to PDF (download here).
Version 4:
This version adds the ability to save your richtext files as PDF. It uses CutePDF Writer (download here) as the engine. You must first save your richtext file as "TempPDF-SaveAsPDF.rtf" then invoke D2R:
Or, if you use the Threading Library:
The attachment includes an example on how to do this.
Version 3:
This version fixes the Winword.exe running process error.
Version 2:
This second version fixes the error were the app crashes if a different version of Word that wasn't Word 2003 was used. D2R now uses Late Binding so converting .doc files to .rtf will be a bit slower. I suggest you bump up the seconds in your app's timer to allow it the necesary time needed to do this. This version doesn't fix the Winword.exe error yet.
Version 1:
You must have Microsoft Word installed in order for this to work. Also, it will cause a funky error and it will open Microsoft Word if the process Winword.exe is actively running on your system (I'll fix this in the near future).
Here's an attachment containing the D2R.exe file and a sample sbp file that shows how this works. The sample is very self explanatory. Enjoy:
Hello friends. This is my small contribution to this great forum and it's my way of saying "thank you" for all the great help you have all given me.
FINALLY! You can now open Word Doc files and load them into your project (for Desktop only).
Well... the method I use basically uses Agraham's Pretty Printing Library to create a Richtextbox in your project, then it uses D2R.exe, a very small program I created (using Visual Basic 6), to literally convert the .doc file into a .rtf file. You can then open your .rtf file using the richtextbox.LoadFile(AppPath & "\file.rtf") command from the Pretty Printing Library.
I use a Shell command to invoke D2R.exe to convert the .doc file. Sample:
B4X:
DocFile = Chr(34) & AppPath & "\Test.doc" & Chr(34)
Shell(AppPath & "\D2R.exe", DocFile)
Or, if you use the Threading Library:
B4X:
DocFile = Chr(34) & AppPath & "\Test.doc" & Chr(34)
Process.Start(AppPath & "\D2R.exe", DocFile)
Do While Process.Running
Sleep(100)
Loop
REQUIREMENTS:
You must have Microsoft Word installed. You also need CutePDF Writer if you want to save your richtext to PDF (download here).
Version 4:
This version adds the ability to save your richtext files as PDF. It uses CutePDF Writer (download here) as the engine. You must first save your richtext file as "TempPDF-SaveAsPDF.rtf" then invoke D2R:
B4X:
DocFile = Chr(34) & AppPath & "\TempPDF-SaveAsPDF.rtf" & Chr(34)
Shell(AppPath & "\D2R.exe", DocFile)
Or, if you use the Threading Library:
B4X:
DocFile = Chr(34) & AppPath & "\TempPDF-SaveAsPDF.rtf" & Chr(34)
Process.Start(AppPath & "\D2R.exe", DocFile)
Do While Process.Running
Sleep(100)
Loop
The attachment includes an example on how to do this.
Version 3:
This version fixes the Winword.exe running process error.
Version 2:
This second version fixes the error were the app crashes if a different version of Word that wasn't Word 2003 was used. D2R now uses Late Binding so converting .doc files to .rtf will be a bit slower. I suggest you bump up the seconds in your app's timer to allow it the necesary time needed to do this. This version doesn't fix the Winword.exe error yet.
Version 1:
You must have Microsoft Word installed in order for this to work. Also, it will cause a funky error and it will open Microsoft Word if the process Winword.exe is actively running on your system (I'll fix this in the near future).
Here's an attachment containing the D2R.exe file and a sample sbp file that shows how this works. The sample is very self explanatory. Enjoy:
Attachments
Last edited: