Solved

VB Control for Word Processing of multiple formats (Word, Excel, TXT, PDF, etc)

Posted on 2001-07-23
23
367 Views
Last Modified: 2010-05-02
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.  
0
Comment
Question by:WizeOne
  • 10
  • 7
  • 3
  • +3
23 Comments
 
LVL 8

Expert Comment

by:Dave_Greene
Comment Utility
How are you importing a file?  CommonDialog?  Commandline?
0
 
LVL 27

Expert Comment

by:Ark
Comment Utility
Use Webbrowser control

Cheers
0
 

Author Comment

by:WizeOne
Comment Utility
Dave,
I'm importing the file by use of CommonDialog.
0
 
LVL 8

Expert Comment

by:Dave_Greene
Comment Utility
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
0
 
LVL 8

Expert Comment

by:Dave_Greene
Comment Utility
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


 
     
0
 

Author Comment

by:WizeOne
Comment Utility
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.
0
 
LVL 8

Expert Comment

by:Dave_Greene
Comment Utility
You could get rid of it.  What do you want to do with the documents/ spreadsheets... whatever?  Just view them?
0
 

Author Comment

by:WizeOne
Comment Utility
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.
0
 

Author Comment

by:WizeOne
Comment Utility
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.
0
 
LVL 8

Expert Comment

by:Dave_Greene
Comment Utility
What do you want to do with the PDF's?  and other files for that matter?
0
 

Author Comment

by:WizeOne
Comment Utility
All I want to do is view the documents.  This functionality is not to allow 'editing'.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 8

Expert Comment

by:Dave_Greene
Comment Utility
You may be able to use (not sure about redistribute) the Adobe Acrobat OCX

Object = "{CA8A9783-280D-11CF-A24D-444553540000}#1.3#0"; "pdf.ocx"'

This would be the most powerful!
0
 

Author Comment

by:WizeOne
Comment Utility
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.
0
 
LVL 8

Expert Comment

by:Dave_Greene
Comment Utility
Good point, keep me posted
0
 
LVL 27

Expert Comment

by:Ark
Comment Utility
Just place WebBrowser control on form.
WebBrowser1.Navigate CommonDialog1.FileName

Cheers
0
 

Author Comment

by:WizeOne
Comment Utility
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...
0
 

Author Comment

by:WizeOne
Comment Utility
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?  
0
 
LVL 27

Expert Comment

by:Ark
Comment Utility
Try
WebBrowser1_DownloadComplete(..)
   On Error Resume Next
   WebBrowser1.Document.ReadOnly = True

Cheers
0
 

Author Comment

by:WizeOne
Comment Utility
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?
0
 

Expert Comment

by:jdmcclanahan
Comment Utility
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.
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
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
0
 

Author Comment

by:WizeOne
Comment Utility
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.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
Comment Utility
Points reduced to 0 and placed in PAQ

Computer101
E-E Moderator
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now