labc Posted January 30, 2008 Report Share Posted January 30, 2008 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 Quote Link to comment
labc Posted February 2, 2008 Author Report Share Posted February 2, 2008 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 Quote Link to comment
ned Posted February 2, 2008 Report Share Posted February 2, 2008 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. Quote Link to comment
labc Posted February 2, 2008 Author Report Share Posted February 2, 2008 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 Quote Link to comment
Jonas Posted February 14, 2008 Report Share Posted February 14, 2008 QUOTE(labc @ Jan 29 2008, 02:21 PM) 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 being 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 The only thing i can think about is to set the mouse position to 0,0 during reporting. OK, it is a "dirty trick" but it does the trick http://sine.ni.com/devzone/cda/epd/p/id/2315 Quote Link to comment
labc Posted February 21, 2008 Author Report Share Posted February 21, 2008 This is an easy vi i wrote. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.