L
luukas9
Hello, (sorry for my english)
I have a form with one WebBrowser object. In this object, I load an
Excel document.
I need / want that user can't copy or cut and paste the data of this
worksheet.
I'm trying to disable the right mouse button but only do it the first
time that I debug the proyect. The Code is this:
The axWBExcell is the WebBrowser object.
private void axWBExcell_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
Microsoft.Office.Interop.Excel.Application xlsApplication
=
(Microsoft.Office.Interop.Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
foreach (Microsoft.Office.Interop.Excel.Worksheet sheet in
xlsApplication.Worksheets)
{
if (!sheet.Name.Contains("myString"))
{
sheet.BeforeRightClick +=
new
Microsoft.Office.Interop.Excel.DocEvents_BeforeRightClickEventHandler(WorkSheet_BeforeRightClick);
}
}
}
protected void
WorkSheet_BeforeRightClick(Microsoft.Office.Interop.Excel.Range
target, ref bool cancel)
{
MessageBox.Show("This option is disable in this sheet");
cancel = true;
}
Someone have any idea how can i do this??? or why this code only is
success one time?? because if i do the same in a macro of excel, it's
success every time!!
Thanks for your help.
I have a form with one WebBrowser object. In this object, I load an
Excel document.
I need / want that user can't copy or cut and paste the data of this
worksheet.
I'm trying to disable the right mouse button but only do it the first
time that I debug the proyect. The Code is this:
The axWBExcell is the WebBrowser object.
private void axWBExcell_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
Microsoft.Office.Interop.Excel.Application xlsApplication
=
(Microsoft.Office.Interop.Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
foreach (Microsoft.Office.Interop.Excel.Worksheet sheet in
xlsApplication.Worksheets)
{
if (!sheet.Name.Contains("myString"))
{
sheet.BeforeRightClick +=
new
Microsoft.Office.Interop.Excel.DocEvents_BeforeRightClickEventHandler(WorkSheet_BeforeRightClick);
}
}
}
protected void
WorkSheet_BeforeRightClick(Microsoft.Office.Interop.Excel.Range
target, ref bool cancel)
{
MessageBox.Show("This option is disable in this sheet");
cancel = true;
}
Someone have any idea how can i do this??? or why this code only is
success one time?? because if i do the same in a macro of excel, it's
success every time!!
Thanks for your help.
).