[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

Read-Only Word document in AxWebBrowser

craigeandrews

6/29/2007 8:25:00 AM

Hi,

I've been trying to find a way to host a 'view' of a Word document in
a Windows Forms app. Ideally I'd like it to be just the document; no
controls or toolbars, and certainly no editing functionality. It seems
that the recommended way is to us the WebBrowser control, and to be
able to access the document once opened, the AxWebBrowser control.

I have the document opening in the web browser control using the
Navigate method and a handler on the NavigateComplete2 event. Getting
the Word document is simple enough, and removing unwanted UI elements
such as toolbars and rules is also easy. However, I can't figure out
how to force the web browser control to open the document read only.
It seems that in the Word object model, the read only flag is a
parameter to the Application.Documents.Open() method, which I never
call thanks to the Navigate interface of the web browser.

Is there a way to force the document to be read only? I thought about
using the document properties, to no avail.

A secondary query I have is that I can't figure out how to remove the
view selection buttons from the horizontal scrollbar without removing
the entire scrollbar. I'd like the view locked to the Print View, and
don't want the user changing.

Any help would be greatly appreciated.

Thanks,

Craig

3 Answers

kris

7/4/2007 4:03:00 AM

0

Hi Craig,

I was trying the similar thing last week and i wasn't able to open the word
document in the browser window....
The word document opens outside the browser.

can you please send me the code snippet on how i can open the word doc in
the browser?

Thanks
Kris

<craigeandrews@gmail.com> wrote in message
news:1183105475.041175.266490@c77g2000hse.googlegroups.com...
> Hi,
>
> I've been trying to find a way to host a 'view' of a Word document in
> a Windows Forms app. Ideally I'd like it to be just the document; no
> controls or toolbars, and certainly no editing functionality. It seems
> that the recommended way is to us the WebBrowser control, and to be
> able to access the document once opened, the AxWebBrowser control.
>
> I have the document opening in the web browser control using the
> Navigate method and a handler on the NavigateComplete2 event. Getting
> the Word document is simple enough, and removing unwanted UI elements
> such as toolbars and rules is also easy. However, I can't figure out
> how to force the web browser control to open the document read only.
> It seems that in the Word object model, the read only flag is a
> parameter to the Application.Documents.Open() method, which I never
> call thanks to the Navigate interface of the web browser.
>
> Is there a way to force the document to be read only? I thought about
> using the document properties, to no avail.
>
> A secondary query I have is that I can't figure out how to remove the
> view selection buttons from the horizontal scrollbar without removing
> the entire scrollbar. I'd like the view locked to the Print View, and
> don't want the user changing.
>
> Any help would be greatly appreciated.
>
> Thanks,
>
> Craig
>


craigeandrews

7/4/2007 10:17:00 AM

0

On 4 Jul, 05:02, "kris" <krish...@yahoo.com> wrote:
> I was trying the similar thing last week and i wasn't able to open the word
> document in the browser window....
> The word document opens outside the browser.
>
> can you please send me the code snippet on how i can open the word doc in
> the browser?

Hi Kris,

I have seen this happen a few times. I used this code:

String strFileName;

//Find the Office document.
openFileDialog1.FileName = "";
openFileDialog1.ShowDialog();
strFileName = openFileDialog1.FileName;
if (strFileName.Length != 0)
{
axWebBrowser1.Navigate(strFileName);
}

This usually works, but if I double-click the file in the open dialog
it will open in an external Word instance. If I select the document
and click OK it will pass the string back properly. This seems to be a
bug in the default implementation of the File dialog rather than the
web browser control.

The only other time I have seen the document open outside the browser
window is when I used the Windows Forms WebBrowser control. It seemed
to try and save the document to the desktop instead of open it, and
when I tried to force it open it opened externally.

On the subject of making a document read only, I found that using the
Document.Protect() method seems to be the way to go. Unfortunate, if
the user presses a key when the document is protected it makes a task
pane appear in the middle of your app ... not ideal, and there doesn't
seem to be a way around it.

HTH,

Craig

Mark Smith

7/11/2007 3:17:00 PM

0

I want to something similar. I want to take information in a database
and create a word document with it. I have the information displaying
in a windows form with different tabs to show the different areas for
input. I want to be able to press a button and have the information put
into the proper format (which I will specify) and be able to save it in
a word document format. Any ideas?



*** Sent via Developersdex http://www.develop... ***