office交流網(wǎng)--QQ交流群號(hào)及微信交流群

Access培訓(xùn)群:792054000         Excel免費(fèi)交流群群:686050929          Outlook交流群:221378704    

Word交流群:218156588             PPT交流群:324131555

微信交流群(請(qǐng)用微信掃碼)

        

VBA讀寫文本文件,打開文件標(biāo)識(shí)符號(hào)句柄 建議使用Freefile

2020-04-23 08:00:00
zstmtony
原創(chuàng)
5832

VBA讀寫文本文件,一般使用下麵的方法,卽打開文件標(biāo)識(shí)符號(hào)句柄 建議使用Freefile


dim i as Integer
i=FreeFile
Open FileName For Input As #i


Open FileName For Input As #1 中的FileName一要用全路徑錶示 


文件標(biāo)識(shí)符號(hào)句柄 建議不要使用 #1 #2
因爲(wèi)你可能會(huì)打開多箇文件(假如)
所以最好使用
dim intFileNo as integer
intFileNo=FreeFile

FreeFile  這箇函數(shù)能自動(dòng)生成沒有使用到的文件句柄編號(hào)

這樣可避免衝突
分享
文章分類
聯(lián)繫我們
聯(lián)繫人: 王先生
Email: 18449932@qq.com
QQ: 18449932
微博: officecn01
移動(dòng)訪問