Jump to content

How to disable mouse in a Excel document?


Recommended Posts

Dear all,

I want to disable mouse in the Excel document using in my office report.

As we know, a cell will be focused if you click or right click a cell of an Excel document, so while the LV is writing data in the template of an Excel document, it would complain an error or some data were missed before you save it as another file.

On the other hand, I prefer to do other Excel work without be disturbed while LV is writing data in the template of an Excel document, even though it's better to set Excel window to display as "no change".

I guess Macro could do the job, could somebody do me a favor?

Labc

Link to comment

Sorry for i've posted my question on another site of LAVA, unfortunatley, nobody reply me.

I want to disable mouse in the Excel document using in my office report.

As we know, a cell will be focused if you click or right click a cell of an Excel document, so while the LabVIEW is writing data in the template of an Excel document, it would complain an error or some data were missed before you save it as another file.

On the other hand, I prefer to do other Excel work without being disturbed while LabVIEW is writing data in the template of an Excel document, even though it's better to set Excel window to display as "no change".

Today, I find it will make some trouble if set mouse as statu of "busy" or "wait". After reading VBA manual of office Excel, i know a property of mouse is "Available", howerver, it's readonly, so may we can't set mouse disable directly.

There are two events of Application.SheetBeforeDoubleClick and Application.SheetBeforeRightClick. i don't know how to control them and guess this would be a good idea.

here are some VBA code as below, all of which can't satisy my requirment:

1,Sub MouseWait()

Application.Cursor = xlWait

End Sub

2,Private Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long

Private Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As Long

Sub subli()

SetCursor (LoadCursor(0, 32514))

End Sub

3, Sub Subli()

Range("A1:A1").Locked = False

ActiveSheet.EnableSelection = xlUnlockedCells

ActiveSheet.Protect UserInterfaceOnly:=False

End Sub

I guess Macro/VBA could do the job, could somebody do me a favor?

Labc

Link to comment

Does the user need to see the Excel sheet while your program is running? Excel has a "Visible" property you can set to false to hide it while you're doing your processing, then set it to true to show the Excel window once you've finished.

Link to comment

QUOTE(ned @ Feb 1 2008, 04:51 PM)

Does the user need to see the Excel sheet while your program is running? Excel has a "Visible" property you can set to false to hide it while you're doing your processing, then set it to true to show the Excel window once you've finished.

Thanks for your quick reply, but it is undesirable if user open another Excel document(A.xls, for an exmple) or are editing it while LV is controlling another one(template.xls).There are 2 situations in detail:

1, LV open the tempalte.xls first ("Visible" property is Fault), then user open A.xls;

2,user open A.xls first then LV do template.xls.

The very important ponit is that wherever you click a cell of A.xls or template.xls while LV is inserting data into template.xls, LV works well before you save template.xls as another name(B.xls, for instance). And then, LV will complain an error or/and you will find some data missed.

Any ideas?

Labc

Link to comment
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.