![]() |
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 |
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 |
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 |
All times are GMT +1. The time now is 09:51 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com