Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run Sub from Button
I found this code to open and close the coffe holder. I pasted it into a
Module Declare Sub mciSendStringA Lib "winmm.dll" (ByVal lpstrCommand As String, ByVal _ lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal _ hwndCallback As Long) Public Sub OpenDefaultDiscTray() mciSendStringA "Set CDAudio Door Open", 0&, 0, 0 End Sub Public Sub CloseDefaultDiscTray() mciSendStringA "Set CDAudio Door Closed", 0&, 0, 0 End Sub Then I added a button the spreadsheet and added this code which doesn't work. i get "Compile Error. Sub or Function not defined." The code to open the CD tray works, but not when i try to call it from a button click event. This seems like it should be really simple, but I don't know what I'm doing wrong. Private Sub CommandButton1_Click() Call OpenDefaultDiscTray End Sub -- Billy Rogers Dallas,TX Currently Using SQL Server 2000, Office 2000 and Office 2003 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run Sub from Button
Billy,
Works for me, though open is a bit slow for some reason...... Where is your code? The Private Sub CommandButton1_Click() should be in the codemodule of the sheet that the button is on. HTH, Bernie MS Excel MVP "BillyRogers" wrote in message ... I found this code to open and close the coffe holder. I pasted it into a Module Declare Sub mciSendStringA Lib "winmm.dll" (ByVal lpstrCommand As String, ByVal _ lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal _ hwndCallback As Long) Public Sub OpenDefaultDiscTray() mciSendStringA "Set CDAudio Door Open", 0&, 0, 0 End Sub Public Sub CloseDefaultDiscTray() mciSendStringA "Set CDAudio Door Closed", 0&, 0, 0 End Sub Then I added a button the spreadsheet and added this code which doesn't work. i get "Compile Error. Sub or Function not defined." The code to open the CD tray works, but not when i try to call it from a button click event. This seems like it should be really simple, but I don't know what I'm doing wrong. Private Sub CommandButton1_Click() Call OpenDefaultDiscTray End Sub -- Billy Rogers Dallas,TX Currently Using SQL Server 2000, Office 2000 and Office 2003 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run Sub from Button
I had it in a module in the Personal.xls I inserted a module and added a
code to the workbook that the button was on and it worked. -- Billy Rogers Dallas,TX Currently Using SQL Server 2000, Office 2000 and Office 2003 "Bernie Deitrick" wrote: Billy, Works for me, though open is a bit slow for some reason...... Where is your code? The Private Sub CommandButton1_Click() should be in the codemodule of the sheet that the button is on. HTH, Bernie MS Excel MVP "BillyRogers" wrote in message ... I found this code to open and close the coffe holder. I pasted it into a Module Declare Sub mciSendStringA Lib "winmm.dll" (ByVal lpstrCommand As String, ByVal _ lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal _ hwndCallback As Long) Public Sub OpenDefaultDiscTray() mciSendStringA "Set CDAudio Door Open", 0&, 0, 0 End Sub Public Sub CloseDefaultDiscTray() mciSendStringA "Set CDAudio Door Closed", 0&, 0, 0 End Sub Then I added a button the spreadsheet and added this code which doesn't work. i get "Compile Error. Sub or Function not defined." The code to open the CD tray works, but not when i try to call it from a button click event. This seems like it should be really simple, but I don't know what I'm doing wrong. Private Sub CommandButton1_Click() Call OpenDefaultDiscTray End Sub -- Billy Rogers Dallas,TX Currently Using SQL Server 2000, Office 2000 and Office 2003 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Inserting a Graphic on a Button when the Button is Assigned to a M | Excel Discussion (Misc queries) | |||
Create floating button based on button click in menu | Excel Programming | |||
Adding .xla button for Toggle Calculation Button | Excel Programming | |||
How do I lock a radio button group if a N/A button is selected | Excel Discussion (Misc queries) | |||
Delete a custom button by holding down the ALT key and dragging the button off the toolbar | Excel Programming |