เพื่อมุ่งให้เกิดคุณภาพจากการอบรมสูงสุด Excel Expert Training ให้การอบรม Excel กลุ่มเล็กๆ ไม่เกิน 6 คนทุกคนสามารถเรียนรู้ Excel อย่างใกล้ชิด จะมาคนเดียวหรือมาเป็นกลุ่มแล้วนัดวันอบรมแบบส่วนตัวก็ได้
ผู้เข้าอบรมทุกคนสามารถติดตามเนื้อหาที่อบรมได้อย่างชัดเจนจากจอภาพด้านหน้าของตัวเอง
-
Cannot quit Microsoft Office Excel จากการใช้ VBA
เรียนถามผู้รู้ค่ะ
เขียน Program Excel VBA ง่ายๆ ที่มีการเปิด Form รับข้อมูลแล้ว write เป็น Text File
ปัญหาคือพอ Exit ออก จากโปรแกรม
แล้ว shut down เครื่อง ฟ้อง message "Cannot quit Microsoft Office Excel "
แก้ปัญหาอย่างไรดีคะ
Pen
-
หาคำตอบพบแล้วค่ะ แต่ไม่แน่ใจ
ไม่แน่ใจว่าจะถูกหรือเปล่านะคะ เจอคำแนะนำจาก http://www.contextures.com/xlfaqmac.html#Close
ขอรบกวนผู้รู้ให้คำแนะนำด้วยค่ะ
How do I close a file/close Excel with a macro? 
ActiveWorkbook.Close savechanges:=False 'true ??? --will close the active workbook Workbooks("mywkbk.xls").Close savechanges:=False 'true ??? --will close mywkbk.xls ThisWorkbook.Close savechanges:=False 'true ??? --will close the workbook that holds the code that's running. Application.Quit will close all of Excel. --Be careful with this one.
-
คำถาม VBA ต้องเขียนให้ชัดครับว่า ส่วนใดที่คนทำ ส่วนใดที่ VBA ทำ
อย่างที่บอกว่า Exit ออกจาก Excel นี้ ใครทำครับ ถ้าคนเป็นคนสั่ง Exit แต่ตัวรหัส VBA ยังทำงานอื่นค้างอยู่ น่าจะเป็นเหตุให้พบคำเตือนนั้น ควรตรวจสอบรหัส VBA ว่าต้องทำงานจบแล้วจริงก่อน (ถ้าใช้ Form ก็ต้องปิด Form ก่อน)
แม้แต่ใช้ VBA สั่ง Exit ก็ต้องจบงานอื่นก่อนเช่นกัน
-
ขอบคุณค่ะ อาจารย์
เป็นการปิดโปรแกรม ที่มีการ เรียกใช้ form ค่ะ และ exit program โดย user กด ที่ ปุ่ม exit แล้ว VBA ฟังก์ชัน cmdClose_Click()
ตามด้วย คำสั่ง unload me
เข้าใจว่า Program คงจะปิด Form ให้เท่านั้น แต่ ไม่ได้ close excel file
ลองทดสอบการใช้ ThisWorkbook.Close savechanges:=False 'true
แล้วใช้ได้ค่ะ เมื่อ กด ปุ่ม exit แล้ว เครื่อง shutdown ได้ค่ะ
Similar Threads
-
By nitcha in forum Excel Expert Forum Library 2012 - 2007
Replies: 6
Last Post: 3 Jul 2009, 07:55
-
By สมเกียรติ in forum My Favorite Tips
Replies: 0
Last Post: 9 Jun 2009, 11:27
-
By khomee in forum Excel Expert Forum Library 2012 - 2007
Replies: 0
Last Post: 24 Apr 2008, 11:03
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules