webrowser -> excel -> deny modifications

H

herb

Hello,

I've following situation:
From a external VBE application (not MS) i open a excel file in a
webbrowser.

Of course it's possible now to edit th excel sheet.

Is it possible to prevent modifications in the loaded excel sheet?

i tried it with disabling the excel alert:

webbrowser1.application.DisplayAlerts = false

.... but it didnt work

Thanks in advance.....
 
N

NickHK

herb,
Don't know about the webbrowser control, but the OLE control can be set to
Interactive=false.
The OLE control takes a little get used to.

NickHK
 
H

herb

thanks for the reply....

i didn't work.... i've tried this:

Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As
Variant)

Set m_oDocument = pDisp.Document

m_oDocument.Application.Interactive = False

End Sub


.... with the effect that nothing happens


the problem is, that the data on the excel sheet are a kind of report,
which of course should be not modified.....
 
N

NickHK

herb,
No, the OLE control has a .Interactive property.
I do not know about the webbrowser control.
Do you have to use the webbrowser ?

NickHK
 
F

fernando

Hi,

if you have access to the excel file you may protect the workbook (and
worksheets).

If not, you may protect the workbook via automation. the workbook (or
maybe worksheet) object should be accesible under the
webbrowser1.document property

hope this helps,

fernando
 
H

herb

fernando said:
Hi,

if you have access to the excel file you may protect the workbook (and
worksheets).

If not, you may protect the workbook via automation. the workbook (or
maybe worksheet) object should be accesible under the
webbrowser1.document property

hope this helps,

fernando


hi,

the webbrowser in vbe doesnt support

webbrowser1.Interactive=false


the reports are generated automatically from an application, so it is
not possible to protect the worksheet while generated.


is it possible to overlay an invisible window to the webbrowser?


hmm.... i'm running out of ideas.....
 
F

fernando

Hi,

I checked the reference for the webbrowser control and I didn't find
the property you want to use.

I also have no idea what application you are using (VB6 / VBA, other?).
Anyway, I hope the code below helps:

'just a Form and a WebBrowser control in VB6 / VBA

Private Sub Form_Load()
'a reference to the excel object library must be declared
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet

'just open any excel file in the webbrowser control
Me.WebBrowser1.Navigate "C:\Mis documentos\libro3.xls" ' change
this file

'the document property in the WebBrowser control is the
Excel.Workbook object
Set wb = Me.WebBrowser1.Document

'once you have access to the Workbook object, you can do pretty
much what you
'like, in this case: protecting the Worksheets

'loop through the worksheets and protect each
For Each ws In wb.Worksheets
ws.Protect
Next

Set ws = Nothing
Set wb = Nothing
End Sub
 
H

herb

hello fernando,

the problem was that the excel sheet should be protect before
displaying.

Private Sub Webbrowser1_NavigateComplete2(ByVal pDisp As Object, URL As
Variant)

.... here the protection-procedure which you have mentioned...

End Sub


....with this it works...


thanks for you help,

Herb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top