:D snasui.com ยินดีต้อนรับ :D
ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย :thup: สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ :arrow: ระบุ Version ของ Excel
:!: โปรดทราบ :!:
  1. กรุณาอ่านกฎการใช้บอร์ด (Forum rules) ในตำแหน่งด้านบนของแต่ละบอร์ด
  2. การสมัครสมาชิก การ Login การกู้คืนรหัสผ่าน
    1. สมัครสมาชิกดูขั้นตอนได้ที่ :arrow: สมัครสมาชิก
    2. Login เข้าระบบโดยคลิกปุ่ม Login ตรงมุมขวาบนของหน้านี้ :roll:
    3. การ Login ผ่าน Facebook ดูวิธีที่ :arrow: Login ผ่าน Facebook
    4. ลืมรหัสผ่านสามารถรับรหัสใหม่ได้ที่ :arrow: Reset รหัสผ่าน
  3. มีปัญหาการใช้งาน แจ้งผู้ดูแลระบบได้ที่ :arrow: ติดต่อผู้ดูแลระบบ
  4. กำหนดการตั้งค่าส่วนตัว เช่นตั้งค่าภาษาเป็นไทยหรืออังกฤษดูได้ที่ :arrow: ตั้งค่าส่วนตัว
  5. การตั้งและตอบกระทู้ดูได้ที่ :arrow: วิธีการตั้งและตอบกระทู้
  6. การจัดรูปแบบตัวอักษรด้วย bbcode ในช่องแสดงความคิดเห็นดูได้ที่ :arrow: จัดรูปแบบตัวอักษร
  7. กำหนดขนาดตัวอักษรใน Browser ดูได้ที่ :arrow: กำหนดขนาดตัวอักษรใน Browser

สอบถามครับการใส่เสียง excel

ฟอรัมถาม-ตอบปัญหาการใช้งานสูตรและฟังก์ชัน Excel
Forum rules
  1. ไม่อนุญาตให้ใช้ภาษาแชทในการถามและตอบปัญหา ไม่ใช้คำว่า "คับ" หรือ "อ่ะครับ" แทนคำว่า "ครับ" ไม่ใช้คำว่า "เด๋ว" แทนคำว่า "เดี๋ยว" เป็นต้น เนื่องจากเมื่อแปลเป็นภาษาต่างประเทศแล้วจะให้ความหมายผิดไปจากที่ควรจะเป็น
  2. ห้ามถามโดยระบุชื่อผู้ตอบและต้องตั้งชื่อกระทู้ให้สื่อถึงปัญหาที่จะถาม ไม่ตั้งชื่อว่า ช่วยด้วยครับ, มีปัญหามาปรึกษาครับ เป็นต้น
  3. กรุณาอธิบายปัญหาและระบุคำตอบที่ต้องการมาในกระทู้ด้วยเสมอถึงแม้จะอธิบายไว้ในไฟล์แนบแล้วก็ตาม ทั้งนี้เพื่ออำนวยความสะดวกแก่เพื่อนสมาชิกในการค้นหาข้อมูล
  4. กรุณาแนบไฟล์ตัวอย่างพร้อมแสดงคำตอบที่ถูกต้องมาในไฟล์ด้วยเพื่อให้ง่ายต่อการทำความเข้าใจและสะดวกต่อการตอบคำถาม (ขนาดไฟล์ไม่เกิน 500Kb ขนาดภาพไม่เกิน 800*600 Pixel) ไม่แนบเป็น Link มาจากแหล่งอื่นที่อาจจะถูกลบทิ้งไปโดยต้นทางในภายหลัง นอกจากนี้ไม่ควรแนบไฟล์ที่มีข้อมูลสำคัญอันก่อให้เกิดความเสียหายกับตนเองและผู้อื่น
  5. กรณีเป็นคำถามเกี่ยวกับ Programming เช่น VBA, VB.Net, C#, SQL ฯลฯ ต้องลองเขียนมาเองก่อนเสมอ ถามเฉพาะที่ติดปัญหา ระบุ Module, Procedure ที่ติดปัญหาให้ชัดเจน กรุณาโพสต์ Code ให้แสดงเป็น Code คือเปิดด้วย [code] และปิดด้วย [/code] ตัวอย่างเช่น [code]dim r as range[/code] เพื่อให้แตกต่างจากข้อความทั่วไป สะดวกในการอ่านและทดสอบ (คลิกเพื่อดูตัวอย่าง)
  6. กรุณาแจ้งผลการใช้งานเมื่อได้รับคำตอบว่าตรงกับความต้องการหรือไม่
Leng
Member
Member
Posts: 225
Joined: Tue Jun 26, 2018 5:19 pm

สอบถามครับการใส่เสียง excel

#1

Post by Leng »

สิ่งที่ต้องการ
- อยากให้เวลาสแกนมีเสียงครับคืออยากให้เวลาข้อมูลบันทึกมีเสียงครับ
- เวลาไม่มีข้อมูลอยากให้ขึ้นอีกเสียงครับ

Code: Select all

Private Sub TextBox5_AfterUpdate()
Dim SoundFile As String, rc As Long
SoundFile = "C:\Users\Administrator\Downloads\A_Drum.wav"

With Workbooks("DataX.xlsx").Worksheets("Sheet1")
Set rngVlp = .Range("a2", .Range("d" & .Rows.Count).End(xlUp))
If Me.TextBox5.Text = "" Then Exit Sub
If WorksheetFunction.CountIf(Workbooks("DataX.xlsx").Worksheets("Sheet1").Range("A:D"), Me.TextBox5.Value) = 0 Then
'Me.TextBox5.Value = ""
MsgBox "Not found."
Exit Sub
End If
    Me.TextBox6.Text = Application.VLookup(CLng(Me.TextBox5.Text), rngVlp, 2, 0)
    Me.TextBox7.Text = Application.VLookup(CLng(Me.TextBox5.Text), rngVlp, 3, 0)
    Me.TextBox8.Text = Application.VLookup(CLng(Me.TextBox5.Text), rngVlp, 4, 0)
End With
With ThisWorkbook.Worksheets("IN")
    emptyrow = .Range("a" & .Rows.Count).End(xlUp).Offset(1, 0).Row
   End With
    With Worksheets("IN")
        .Cells(emptyrow, 1).Value = TextBox1.Value
        .Cells(emptyrow, 2).Value = TextBox2.Value
        .Cells(emptyrow, 3).Value = TextBox4.Value
        .Cells(emptyrow, 4).Value = ComboBox1.Value
        .Cells(emptyrow, 5).Value = TextBox5.Value
        .Cells(emptyrow, 6).Value = TextBox6.Value
        .Cells(emptyrow, 7).Value = TextBox7.Value
        .Cells(emptyrow, 8).Value = TextBox8.Value
        .Cells(emptyrow, 9).Value = TextBox9.Value
    End With
End Sub
You do not have the required permissions to view the files attached to this post.
User avatar
snasui
Site Admin
Site Admin
Posts: 31257
Joined: Sun Jan 24, 2010 12:33 pm
Location: Songkhla, Thailand
Excel Ver: 2010, 2019
Contact:

Re: สอบถามครับการใส่เสียง excel

#2

Post by snasui »

:D การเรียกไฟล์เสียงไม่ง่ายสำหรับมือใหม่ครับ

ดูตัวอย่างที่นี่ครับ https://www.snasui.com/viewtopic.php?t=11648
Leng
Member
Member
Posts: 225
Joined: Tue Jun 26, 2018 5:19 pm

Re: สอบถามครับการใส่เสียง excel

#3

Post by Leng »

อาจารย์ครับตอนนี้มีเสียงแล้วแต่เวลา แสกนไม่มีมีเสียง ครับ

Code: Select all

Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
(ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Sub notift()
    Dim SoundFile As String, rc As Long
    SoundFile = "C:\WINDOWS\Media\ringout.wav"
    rc = mciSendString("Play " & SoundFile, "", 0, 0)
    Debug.Print rc
End Sub

ผมไม่รู้ตั้งอะไรผิดรบกวนอาจารย์ช่วยดูหน่อยครับ
You do not have the required permissions to view the files attached to this post.
User avatar
snasui
Site Admin
Site Admin
Posts: 31257
Joined: Sun Jan 24, 2010 12:33 pm
Location: Songkhla, Thailand
Excel Ver: 2010, 2019
Contact:

Re: สอบถามครับการใส่เสียง excel

#4

Post by snasui »

:D การจะให้เสียงทำงานจะต้อง Call จาก Code ที่ทำงานเมื่อมีการ Scan ครับ

Code ที่ทำงานเมื่อมีการ Scan เขียนไว้ว่าอย่างไร เขียนเรียกไฟล์เสียงแล้วหรือไม่ โพสต์ประกอบมาด้วยจะได้ช่วยดุให้ได้ครับ
Leng
Member
Member
Posts: 225
Joined: Tue Jun 26, 2018 5:19 pm

Re: สอบถามครับการใส่เสียง excel

#5

Post by Leng »

Code: Select all

Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
(ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

Sub Sample2()
Worksheets("in").Range("A3:D1048576") = ""
    Dim SoundFile As String, rc As Long
    SoundFile = "C:\Windows\Media\tada.wav"
    If Dir(SoundFile) = "" Then
        MsgBox SoundFile & vbCrLf & "isNothing", vbExclamation
        Exit Sub
    End If
    rc = mciSendString("Play " & SoundFile, "", 1, 0)
End Sub
รบกวนอาจารย์ช่วยดูหน่อยครับ
You do not have the required permissions to view the files attached to this post.
User avatar
snasui
Site Admin
Site Admin
Posts: 31257
Joined: Sun Jan 24, 2010 12:33 pm
Location: Songkhla, Thailand
Excel Ver: 2010, 2019
Contact:

Re: สอบถามครับการใส่เสียง excel

#6

Post by snasui »

:D ไฟล์ล่าสุดนี้ผมไม่สามารถเปิดดูได้

กรุณาแนบมาใหม่ ตัด Code ที่ไม่เกี่ยวข้องทิ้งไปเช่นการขยาย Form การซ่อนเมนู ฯลฯ ครับ
Leng
Member
Member
Posts: 225
Joined: Tue Jun 26, 2018 5:19 pm

Re: สอบถามครับการใส่เสียง excel

#7

Post by Leng »

รบกวนอาจารย์ด้วยครับ
You do not have the required permissions to view the files attached to this post.
User avatar
snasui
Site Admin
Site Admin
Posts: 31257
Joined: Sun Jan 24, 2010 12:33 pm
Location: Songkhla, Thailand
Excel Ver: 2010, 2019
Contact:

Re: สอบถามครับการใส่เสียง excel

#8

Post by snasui »

Leng wrote: Mon Jul 30, 2018 6:09 pm อยากให้เวลาสแกนมีเสียงครับคืออยากให้เวลาข้อมูลบันทึกมีเสียงครับ
:D ตัวอบ่างการ Call Procedure เมื่อมีการสแกนแล้วเรียกไฟล์เสียงครับ

Code: Select all

'Other code
With Worksheets("IN")
    .Cells(emptyrow, 1).Value = TextBox1.Value
    .Cells(emptyrow, 2).Value = TextBox2.Value
    .Cells(emptyrow, 3).Value = TextBox4.Value
    .Cells(emptyrow, 4).Value = ComboBox1.Value
    .Cells(emptyrow, 5).Value = TextBox5.Value
    .Cells(emptyrow, 6).Value = TextBox6.Value
    .Cells(emptyrow, 7).Value = TextBox7.Value
    .Cells(emptyrow, 8).Value = TextBox8.Value
    .Cells(emptyrow, 9).Value = TextBox9.Value
    Call Sample2
End With
'Other code
หากมีเงื่อนไขว่ากรณีมีการบันทึกให้เรียกไฟล์เสียงไฟล์หนึ่ง หากไม่มีการบันทึกให้เรียกไฟล์เสียงอีกไฟล์หนึ่ง ลองปรับปรุง Code มาเองก่อนติดแล้วค่อยถามกันครับ
Leng
Member
Member
Posts: 225
Joined: Tue Jun 26, 2018 5:19 pm

Re: สอบถามครับการใส่เสียง excel

#9

Post by Leng »

ได้ละครับขอบพระคุณมากครับ :D :D
Post Reply