geno32080
Board Regular
- Joined
- Jan 23, 2020
- Messages
- 112
- Office Version
- 2013
- Platform
- Windows
This may sound crazy, but, as we all love experimenting with excel boundaries here goes.
I have a command button that imports files and pastes to individual sheets, this process takes about 5 seconds, I have this code that starts and stops a mid file, is it possible to have the mid file play while the files are importing and pasting? The mid file needs to run 5 seconds I can adjust it once I get it to work with the button.
This works when I run the sub manually. I would like to intergrate it with Private Sub CommandButton below, that's an abbreviated version, it does a total of 8 sheets. Thanks for taking the time. Help is always appreciated. I have a presentation coming up to show the workbook, hoping the music will liven up the presentation a bit.
Private Declare Function mciExecute Lib "winmm.dll" _
(ByVal lpstrCommand As String) As Long
Sub Midi(action As String, midiFilename)
If Dir(midiFilename) = "" Then
MsgBox midiFilename & vbCrLf & "Does Not Exist."
Exit Sub
End If
mciExecute action & " " & midiFilename
End Sub
Sub PlayMIDI()
Dim mf As String
mf = "C:\Windows\Media\onestop.mid"
Midi "play", mf
End Sub
Sub StopMIDI()
Dim mf As String
mf = "C:\Windows\Media\onestop.mid"
Midi "stop", mf
End Sub
Private Sub CommandButton1_Click()
Dim sourceworkbook As Workbook
Set sourceworkbook = Workbooks.Open("C:\JEN FOLDER\IMPORT\Jacksonville.csv")
sourceworkbook.Sheets("Jacksonville").Range("A3:S98").Copy
ThisWorkbook.Worksheets("jax").Range("B9").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
sourceworkbook.Close
Set sourceworkbook = Nothing
Me.Hide
End Sub
I have a command button that imports files and pastes to individual sheets, this process takes about 5 seconds, I have this code that starts and stops a mid file, is it possible to have the mid file play while the files are importing and pasting? The mid file needs to run 5 seconds I can adjust it once I get it to work with the button.
This works when I run the sub manually. I would like to intergrate it with Private Sub CommandButton below, that's an abbreviated version, it does a total of 8 sheets. Thanks for taking the time. Help is always appreciated. I have a presentation coming up to show the workbook, hoping the music will liven up the presentation a bit.
Private Declare Function mciExecute Lib "winmm.dll" _
(ByVal lpstrCommand As String) As Long
Sub Midi(action As String, midiFilename)
If Dir(midiFilename) = "" Then
MsgBox midiFilename & vbCrLf & "Does Not Exist."
Exit Sub
End If
mciExecute action & " " & midiFilename
End Sub
Sub PlayMIDI()
Dim mf As String
mf = "C:\Windows\Media\onestop.mid"
Midi "play", mf
End Sub
Sub StopMIDI()
Dim mf As String
mf = "C:\Windows\Media\onestop.mid"
Midi "stop", mf
End Sub
Private Sub CommandButton1_Click()
Dim sourceworkbook As Workbook
Set sourceworkbook = Workbooks.Open("C:\JEN FOLDER\IMPORT\Jacksonville.csv")
sourceworkbook.Sheets("Jacksonville").Range("A3:S98").Copy
ThisWorkbook.Worksheets("jax").Range("B9").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
sourceworkbook.Close
Set sourceworkbook = Nothing
Me.Hide
End Sub