BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

excel disable click

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Roberto Salvatierra
Guest





PostPosted: Sat Jul 08, 2006 8:12 am    Post subject: excel disable click Reply with quote



hi ! I have been reading posts over and over.. but I have not found an
answer and i have tried really
my main problem is that i need to really protect a worksheet and when I mean
really i mean total
protection so far i have been able to open " oc1.CreateObject('Excel.Sheet',
False); "
then load a stream to it, get rid of the toolbars, (
oc1.oleobject.CommandBars ) and make the ones active to false, and use the
embeded protection of the worksheet to keep it protected. now the only
problem that i have, and it's because of more knowledge is that i need to
disable all right clicks
on the page.

According to MSDN this function exists:

Excel Object Model Reference (Visual Studio Tools for Office)
Worksheet.BeforeRightClick Event
Occurs when the worksheet is right-clicked, before the default right-click
action.

and i found a nice example of how to use it on visual basic:

----------------------------------------
MSDN ---------------------------------------

Visual Basic (Declaration)
Public Event BeforeRightClick As DocEvents_BeforeRightClickEventHandler
Visual Basic (Usage)
Dim instance As Worksheet
Dim handler As DocEvents_BeforeRightClickEventHandler

AddHandler instance.BeforeRightClick, handler
The following code example demonstrates a handler for the BeforeRightClick
event that cancels the right-click action on the current worksheet. The
event handler informs the user that right-clicking is not allowed for the
worksheet, and then sets the Cancel parameter of the
DocEvents_BeforeRightClickEventHandler event handler to true so that
Microsoft Office Excel cancels the right-click action.

Visual Basic

Sub Worksheet1_BeforeRightClick(ByVal Target As Excel.Range, _
ByRef Cancel As Boolean) Handles Me.BeforeRightClick
MsgBox("Right-clicking in this sheet" & " is not allowed.")
Cancel = True
End Sub

----------------------------------------
MSDN ---------------------------------------

now I would like to translate this to delphi, but I have not been able to do
it...
can someone help me implemet it in delphi ?

TYIA/

Roberto Salvatierra
Back to top
Chris Cheney
Guest





PostPosted: Sat Jul 08, 2006 3:59 pm    Post subject: Re: excel disable click Reply with quote



"Roberto Salvatierra" <chuby (AT) internettico (DOT) com> wrote in
news:44af506b (AT) newsgroups (DOT) borland.com:

<snip>
Quote:
and i found a nice example of how to use it on visual basic:

snip

Sub Worksheet1_BeforeRightClick(ByVal Target As Excel.Range, _
ByRef Cancel As Boolean) Handles Me.BeforeRightClick
MsgBox("Right-clicking in this sheet" & " is not allowed.")
Cancel = True
End Sub

----------------------------------------
MSDN ---------------------------------------

now I would like to translate this to delphi, but I have not been able
to do it...
can someone help me implemet it in delphi ?

It would help to know which version of Delphi so that we know what
facilities you have available to you. For example, there is much more code
needed for Delphi 3 than say Delphi 7 Professional (or later).

Assuming that you have a version of Delphi (e.g D7Pro) that provides the
Excel Component wrappers (see the Servers tab in the component palette),
drop an ExcelWorksheet component onto the form. Select this in the Object
Inspector and on its Events tab, double-click the box to the right of the
OnBeforeRightClick item - this will generate prototype code of the form

procedure TForm1.ExcelWorksheet1BeforeRightClick(ASender: TObject;
const Target: ExcelRange; var Cancel: WordBool);
begin

end;

Add the code

ShowMessage('Right-clicking in this sheet is not allowed.');
Cancel := True;

between the begin and end in the body of this routine.

--
For e-mail address, remove the XXs
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.