您的位置:程序门 -> vb -> vba



excelvba选择文件名输出文本问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


excelvba选择文件名输出文本问题[已结贴,结贴人:ggce]
发表于:2007-11-26 10:53:59 楼主
请帮帮忙,本人第一次写这种东西。看看我这个写的对不对(肯定不对,都运行不了),应该怎么写,谢谢!
private   sub   commandbutton2_click()

写入文本文件
end   sub

sub   写入文本文件()
        fd   =   application.getopenfilename(filefilter:="   文本文件(*.txt),*.txt",   title:="请选择写入文件")
        open   fd   for   output   as   fn
        i   =   1
        do
                if   cells(i,   1).text   =   ""   then   exit   do
                print   #fn,   cells(i,   1).text
                i   =   i   +   1
        loop
        close   #fn
end   sub
发表于:2007-11-26 13:25:071楼 得分:5
写入文本文件()  
过程名不能使用中文
open       fd       for       output       as       fn  
这里是fd

close       #fn   这里怎么是fn了   ??


发表于:2007-11-26 14:06:162楼 得分:0
写入文本文件()      
过程名不能使用中文  
open               fd               for               output               as               fn      
这里是fd  

close               #fn       这里怎么是fn了       ??  
===========================================================
过程名可以使用中文
fd是文件名,fn是文件号。
发表于:2007-11-26 14:06:593楼 得分:95
vbscript code
fd = application.getopenfilename(filefilter:=" 文本文件(*.txt),*.txt", title:="请选择写入文件") fn = freefile() open fd for output as fn i = 1 do if cells(i, 1).text = "" then exit do print #fn, cells(i, 1).text i = i + 1 loop close #fn
发表于:2007-11-26 14:28:074楼 得分:0
谢谢,搞定!


快速检索

最新资讯
热门点击