Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting a Graphic on a Button when the Button is Assigned to a M smck Excel Discussion (Misc queries) 2 October 27th 09 04:46 PM
Create floating button based on button click in menu ExcelMonkey Excel Programming 2 October 12th 05 06:43 PM
Adding .xla button for Toggle Calculation Button Mike Excel Programming 5 August 19th 05 01:55 PM
How do I lock a radio button group if a N/A button is selected worry a lot Excel Discussion (Misc queries) 2 May 21st 05 08:33 PM
Delete a custom button by holding down the ALT key and dragging the button off the toolbar Stephen[_8_] Excel Programming 0 April 4th 04 02:22 PM


All times are GMT +1. The time now is 06:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"