CommonDialog控件
生活随笔
收集整理的這篇文章主要介紹了
CommonDialog控件
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
'要先單擊“工程-部件”,顯示“部件”對話框,將“Microsoft Common Dialog control 6.0(SP6)”選中,在工具欄就多出了一個CommonDialog控件圖標(biāo),將其添加到窗體上
Private Sub Command1_Click()
CommonDialog1.CancelError = True
CommonDialog1.DialogTitle = "選定要打開的Excel文件"
CommonDialog1.InitDir = App.Path
CommonDialog1.Filter = "Xls文件(*.Xls)|*.Xls|所有文件(*.*)|*.*"
CommonDialog1.InitDir = App.Path
CommonDialog1.ShowOpen
If Err <> cdlCancel ThenTxtFileName = CommonDialog1.FileName
ElseExit Sub
End If
Set xlApp = CreateObject("Excel.Application") '創(chuàng)建EXCEL對象
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Open(TxtFileName)
End Sub
注意最后要關(guān)閉
On Error Resume Next
xlBook.Save
xlBook.Close (True) '關(guān)閉工作簿.............................................
xlApp.Quit '結(jié)束EXCEL對象....................................................
Set xlApp = Nothing '釋放xlApp對象.............................................!!!
轉(zhuǎn)載于:https://www.cnblogs.com/lbnnbs/p/4784835.html
總結(jié)
以上是生活随笔為你收集整理的CommonDialog控件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Kruskal Prim模板
- 下一篇: C语言字符串操作常用库函数