更新1:
原來我要用的是VB6的系統= ="難怪在VBA都沒問題!! cheng大...想要再請教若在VB6內如何運作了... Workbooks.Open DirPath & fs 這句在VB6內一直說此處需要物件... 而且好像不能對應KEYCODE 13...我把代碼改成如下...但還是不行... Private Sub textbox1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Tx = textbox1 & ".xlsm" DirPath = "K:\testroad\" fs = Dir(DirPath & "*.xlsm") Do Until fs = "" r = r + 1 If fs = Tx Then Workbooks.Open DirPath & fs textbox1 = "" Exit Sub End If fs = Dir Loop Workbooks.Open DirPath & "test123.xlsm" textbox1 = "" End If 再麻煩大大了@@"感恩