|
-
Feb 22nd, 2012, 01:54 PM
#1
WebBrowser control to show Word.doc
In trying to reply to another thread, I came
upon an apparent technique to "embed" a
Word doc on a VB6 form using a WebBrowser
control, as follows
Code:
Dim myFile As String
myFile = "c:\myWord.doc"
With WebBrowser1
.Top = 100
.Left = 100
.Height = 5000
.Width = 12000
.Visible = True
.Navigate2 myFile
End With
It works great. The doc appears (along with
scroll bars) and has the look and feel of Word.
But, I say "apparent" because before the doc is
loaded, a File Download dialogue box appears
with buttons
and a warning regarding potential harm from
files from the Internet.
In a "normal" web browsing situation, this warning
is definitely a good thing.
But here, since a "trusted" file path was specified,
the warning is a "nuisance".
From MSDN regarding Navigate2 Method:
- Description
Navigates to the resource identified by a Universal Resource Locator (URL)
or to the file identified by a full path. The Navigate2 method extends the
Navigate method to support browsing on special folders—such as Desktop
and My Computer—that are represented by a pointer to an item identifier list
(PIDL). However, this is not applicable to the Visual Basic programming
language. For information on this functionality, see the Using the WebBrowser
Control from C/C++ section. - Syntax
object.Navigate2 URL [Flags,] [TargetFrameName,] [PostData,] [Headers] - Part, Description
- object Required. An object expression that evaluates to an object
in the Applies To list. - URL Required. A string expression that evaluates to the URL of the
resource to display or the full path to the file location. - Flags Optional. A constant or value that specifies whether to add
the resource to the history list, whether to read from or write to the cache,
and whether to display the resource in a new window. It can be a
combination of the following constants or values. - Flags .. Constant Value Meaning
- navOpenInNewWindow ... 1 Open the resource or file in a new window.
- navNoHistory ................. 2 Do not add the resource or file to the history list.
The new page replaces the current page in the list. - navNoReadFromCache ... 4 Do not read from the disk cache for this navigation.
- navNoWriteToCache ....... 8 Do not write the results of this navigation to the disk cache.
I then tried adding a flag ...
Code:
Dim myFile As String
myFile = "c:\myWord.doc"
With WebBrowser1
.Top = 100
.Left = 100
.Height = 5000
.Width = 12000
.Visible = True
.Navigate2 myFile, navNoWriteToCache
End With
... but I still get the dialogue box.
Is there a way to convince VB that it is a trusted
source and thereby prevent the dialogue box from
appearing at all?
Spoo
-
Feb 22nd, 2012, 04:13 PM
#2
Re: WebBrowser control to show Word.doc
The only way I see to get rid of the dialog is to uncheck the little always ask box.
In theory you may be able to modify the registery entery for this option before executing the call then change it back afterwards but I have not looked into this to see what it would take.
Maybe this would be of some help
http://www.winhelponline.com/blog/re...-file-setting/
-
Feb 22nd, 2012, 09:23 PM
#3
Re: WebBrowser control to show Word.doc
DataMiser
Yeah, I thought of unchecking the little "always ask" box,
but would prefer not to.
I like your registry entry approach much better. I'll check
it out. Thanks
Spoo
-
Feb 22nd, 2012, 09:40 PM
#4
Re: WebBrowser control to show Word.doc
You're welcome,
I did uncheck it, stumbled across that site looking for a way to re-activate it afterwards
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|