WizeOne
asked on
VB Control for Word Processing of multiple formats (Word, Excel, TXT, PDF, etc)
Within my application, I'm currently using OLE Automation that allows a user to import an existing document of Word or Text format. Once imported, the user can View the file.
But I'm searching for a more powerful control that will allow the user to import a document into the application which will support the following formats Word, Excel, Text and most importantly, PDF...and still be able to view the document imported within the application.
Think of it as MS Word but without capability of making modifications to the document.
This question may not be so much as technical...unless someone has VB Code to handle my criteria, but rather more of a question if someone knows of an existing control or software tool that can be useful in a VB Project. So for me...and my application I give this higher points rated on it's level of importance more than the level of difficulty. Although, this has been difficult for me because I have yet to find a control from my internet searchings.
But I'm searching for a more powerful control that will allow the user to import a document into the application which will support the following formats Word, Excel, Text and most importantly, PDF...and still be able to view the document imported within the application.
Think of it as MS Word but without capability of making modifications to the document.
This question may not be so much as technical...unless someone has VB Code to handle my criteria, but rather more of a question if someone knows of an existing control or software tool that can be useful in a VB Project. So for me...and my application I give this higher points rated on it's level of importance more than the level of difficulty. Although, this has been difficult for me because I have yet to find a control from my internet searchings.
How are you importing a file? CommonDialog? Commandline?
Use Webbrowser control
Cheers
Cheers
ASKER
Dave,
I'm importing the file by use of CommonDialog.
I'm importing the file by use of CommonDialog.
Well then you can set your OLE container to whichever object you want to create.
Here is an example of creating an instance of MediaPlayer on the fly. In this example the MP2 Object is dimensioned as "MediaPlayer.MediaPlayer" so that you can have control over the events the OLE object will create. See EndofStream method...
Add an OLE container to your form and add this code.
Option Explicit
Private WithEvents MP2 As MediaPlayer.MediaPlayer
Private Sub Form_Load()
With OLE1
.CreateEmbed vbNullString, "MediaPlayer.MediaPlayer.1 "
Set MP2 = .object
End With
MP2.filename = "C:\bong.wav"
MP2.ShowDisplay = False
MP2.ClickToPlay = True
End Sub
Private Sub MP2_EndOfStream(ByVal Result As Long)
MsgBox "EOS"
End Sub
Here is an example of creating an instance of MediaPlayer on the fly. In this example the MP2 Object is dimensioned as "MediaPlayer.MediaPlayer" so that you can have control over the events the OLE object will create. See EndofStream method...
Add an OLE container to your form and add this code.
Option Explicit
Private WithEvents MP2 As MediaPlayer.MediaPlayer
Private Sub Form_Load()
With OLE1
.CreateEmbed vbNullString, "MediaPlayer.MediaPlayer.1
Set MP2 = .object
End With
MP2.filename = "C:\bong.wav"
MP2.ShowDisplay = False
MP2.ClickToPlay = True
End Sub
Private Sub MP2_EndOfStream(ByVal Result As Long)
MsgBox "EOS"
End Sub
So for your application
you would parse out the commondialog filename for it's extension and create the object accordingly
Select Case strExt
Case "Doc"
OLE1.CreateEmbed vbNullString, "Word.Application"
Case "Xls"
OLE1.CreateEmbed vbNullString, "Excel.Application"
Case ETC...
End Select
Set MyOle = Ole1.object
you would parse out the commondialog filename for it's extension and create the object accordingly
Select Case strExt
Case "Doc"
OLE1.CreateEmbed vbNullString, "Word.Application"
Case "Xls"
OLE1.CreateEmbed vbNullString, "Excel.Application"
Case ETC...
End Select
Set MyOle = Ole1.object
ASKER
Dave,
I'll try this ... but I was kind of hoping to get rid of OLE Automation since it uses up a lot of resources.
I'll try this ... but I was kind of hoping to get rid of OLE Automation since it uses up a lot of resources.
You could get rid of it. What do you want to do with the documents/ spreadsheets... whatever? Just view them?
ASKER
Dave,
I'll try this ... but I was kind of hoping to get rid of OLE Automation since it uses up a lot of resources.
I'll try this ... but I was kind of hoping to get rid of OLE Automation since it uses up a lot of resources.
ASKER
Dave,
Your code works for Word, Excel, Tif files, etc but I'm not able to get OLE to support PDF files. Any thoughts?
Maybe I should just use Web Browser. I'm aware of web browser control but I was hoping to find something more powerful.
Your code works for Word, Excel, Tif files, etc but I'm not able to get OLE to support PDF files. Any thoughts?
Maybe I should just use Web Browser. I'm aware of web browser control but I was hoping to find something more powerful.
What do you want to do with the PDF's? and other files for that matter?
ASKER
All I want to do is view the documents. This functionality is not to allow 'editing'.
You may be able to use (not sure about redistribute) the Adobe Acrobat OCX
Object = "{CA8A9783-280D-11CF-A24D- 4445535400 00}#1.3#0" ; "pdf.ocx"'
This would be the most powerful!
Object = "{CA8A9783-280D-11CF-A24D-
This would be the most powerful!
ASKER
Interesting point. I wasn't aware of this ocx. I'm sure redistribution isn't a problem, as long as the user a Acrobat installed on their PC...but the control is not supported by Adobe Acrobat.
In looking up about the control, it was built to integrate with Windows Explorer.
So maybe this control combined with disable some of the functionality of WebBrowser is my answer.
In looking up about the control, it was built to integrate with Windows Explorer.
So maybe this control combined with disable some of the functionality of WebBrowser is my answer.
Good point, keep me posted
Just place WebBrowser control on form.
WebBrowser1.Navigate CommonDialog1.FileName
Cheers
WebBrowser1.Navigate CommonDialog1.FileName
Cheers
ASKER
Ark,
I'm aware of the WebBrowser control... the down side is I would need to disable some of the uses within WebBrowser. For example, the documents are for viewing, so I would need to disable editing capabilities along with the menu bar, and the right mouse click.
I was hoping to find something a little more powerful, but I'm finding that so far there is nothing else to use...
I'm aware of the WebBrowser control... the down side is I would need to disable some of the uses within WebBrowser. For example, the documents are for viewing, so I would need to disable editing capabilities along with the menu bar, and the right mouse click.
I was hoping to find something a little more powerful, but I'm finding that so far there is nothing else to use...
ASKER
I've now concluded (after working in-between several projects) that WebBrowser control is currently the most capable container to support what I'm looking to do. (see original question).
My difficulty now is... How can I disable the editing a word, excel, etc. document within the WebBrowser? I only want to view/scroll the document and not allow for the ruler bar to show, change the text, etc.
The same is true for the right mouse click event, how can I turn this off?
My difficulty now is... How can I disable the editing a word, excel, etc. document within the WebBrowser? I only want to view/scroll the document and not allow for the ruler bar to show, change the text, etc.
The same is true for the right mouse click event, how can I turn this off?
Try
WebBrowser1_DownloadComple te(..)
On Error Resume Next
WebBrowser1.Document.ReadO nly = True
Cheers
WebBrowser1_DownloadComple
On Error Resume Next
WebBrowser1.Document.ReadO
Cheers
ASKER
Ark,
Thank you for your code, but I'm getting the following results:
Error Number: 438
Description: Object doesn't support this property or method
Any thoughts?
Thank you for your code, but I'm getting the following results:
Error Number: 438
Description: Object doesn't support this property or method
Any thoughts?
If you try setting the ReadOnly property for an OLE container with a Word document, you get the error that the property is read only. I assume its also true for the Web Browser control.
Hi WizeOne,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Accept Ark's comment(s) as an answer.
WizeOne, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you. DO NOT accept this comment as an answer.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Accept Ark's comment(s) as an answer.
WizeOne, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you. DO NOT accept this comment as an answer.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
ASKER
Hello DanRollins,
I haven't forgotten the question. The project I was working on for needing this question has been canceled. A few months later my employer was hit by the economy down fall and let a few of us go...including me.
At the moment I'm unemployed in the technical world but for my own resources I'm still looking for an answer. Ark's answer was one that I was aware of but not what I'm looking for.
For now, mabye we should just remove the question.
I haven't forgotten the question. The project I was working on for needing this question has been canceled. A few months later my employer was hit by the economy down fall and let a few of us go...including me.
At the moment I'm unemployed in the technical world but for my own resources I'm still looking for an answer. Ark's answer was one that I was aware of but not what I'm looking for.
For now, mabye we should just remove the question.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.