Hi Ryan,
It's definitely possible. Assuming the CommandButton is from the ActiveX
toolbox, you can do something like this to set its visibility:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
cmdTest.Enabled = Len(Dir$("G:\Assets\test.doc"))
End Sub
[change "cmdTest" to whatever your CommandButton is named]
Place this code on the Worksheet in which the CommandButton resides
(right-click sheet tab in Excel and select View Code), and the check will be
performed every time the selection is changed on that Worksheet.
NOTE: This will slow down navigation somewhat, especially if you have a
slow network connection to the G drive. If you only want to check for file
existence when the Workbook is first opened, you can put the code in the
ThisWorkbook module (Workbook_Open event routine).
--
Regards,
Jake Marx
MS MVP - Excel
www.longhead.com
[please keep replies in the newsgroup - email address unmonitored]
Ryan wrote:
I don't think that what I am proposing to do is possible, but it is
worth a shot (and will make my boss happy which is always a good
thing). I want to be able to set a condition for the visibility of a
command button. I want the button hidden unless there is a certain
file in a certian drive. I have yet to be given the specifics on
what the file will be and where it wil be, so for now I will call the
file "test.doc" and the location "G:\Assets\". When "test.doc" is in
"G:\Assets\" I want CommandButton1 on Sheet1 to be visible. When
"test.doc" is NOT in "G:\Assets\" I want CommandButton1 to NOT be
visible.
Thanks for your help!
Ryan