OLE1 - WebBrowser1 - Word Doc

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

OLE1 - WebBrowser1 - Word Doc

Post by D Willett »

Working away from my usual grain of PDF files, I have many Word doc files I would like to incorporate within my project.
I can load into an OLE control:

Code: Select all

    If Right(File1.FileName, 4) = "doc" Then
    Me.OLE1.Visible = True
    Me.AcrobatPath.Text = (File1.Path & "\" & File1.FileName)
    Me.OLE1.CreateEmbed SourceDoc:=AcrobatPath
    Me.AcroPDF1.Visible = False
That looks very clunky and formatting, ie fonts, page length etc are not good.
There again I can open a doc with a WeBrowser control:

Code: Select all

     Dim strUrl As String
    strUrl = (File1.Path & "\" & File1.FileName)
    WebBrowser1.Navigate strUrl
Only this opens Word and the document instead of inside the control.

The question being, can I open a word document in a container that fits within my form and edit it if necessary?
Cheers ...

Dave.

User avatar
HansV
Administrator
Posts: 78530
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: OLE1 - WebBrowser1 - Word Doc

Post by HansV »

In which application are you trying to do this?
Best wishes,
Hans

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Re: OLE1 - WebBrowser1 - Word Doc

Post by D Willett »

Sorry Hans.

VB6
Cheers ...

Dave.

User avatar
HansV
Administrator
Posts: 78530
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: OLE1 - WebBrowser1 - Word Doc

Post by HansV »

Does VB6 have the option to display the embedded document as an icon?
Best wishes,
Hans

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Re: OLE1 - WebBrowser1 - Word Doc

Post by D Willett »

Yes OLE1 does.
Can't see the option in the WebBrowser control.
Cheers ...

Dave.

User avatar
HansV
Administrator
Posts: 78530
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: OLE1 - WebBrowser1 - Word Doc

Post by HansV »

If you set the OLE1 control to display as an icon, you should be able to double-click the icon to edit the document in Word, and when you save the document it should be saved in the OLE1 control.
Best wishes,
Hans

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Re: OLE1 - WebBrowser1 - Word Doc

Post by D Willett »

Cheers Hans.
It works, its a bit ugly though.

Just looking more at:

Code: Select all

If Right(File1.FileName, 3) = "doc" Then
    WebBrowser1.Navigate ""
    strUrl = (File1.Path & "\" & File1.FileName)
    WebBrowser1.Navigate strUrl
Else
This opens the doc straight from the list "File1" into Word and looks pretty ok, just bombs out on the odd occasion so efficiency wise could do with improving.
Obviously it would be ideal to have the doc in the web control but I can live with it's current action.
Any improvements to the code efficiency would be great.

Cheers
Cheers ...

Dave.