码迷,mamicode.com
首页 > 编程语言 > 详细

VBA读取文件

时间:2015-05-29 19:43:29      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:

Dim Foldar As String
Private Sub btn(ByVal Target As Range)
    If Target.Row = 1 And Target.Column = 1 Then
     Search
    End If
End Sub

 

Sub Search()
    With Application.FileDialog(msoFileDialogFolderPicker)
        If .Show = True Then
            Foldar = .SelectedItems(1)
            ‘Range("D3").Value = Foldar
            selectjs (Foldar)
        End If
    End With
End Sub

 

 

Public Function selectjs(ByVal lujing As String)

    Dim MyFile As String

    Dim s As String     

   Dim i As Integer    

MyFile = Dir(lujing & "\" & "*.js")    

count = count + 1    

s = MyFile   

  output (s)     Do While MyFile <> ""      

   MyFile = Dir                

If MyFile = "" Then        

count = 0             Exit Do

        End If      

           count = count + 1     

        s = MyFile      

   output (s)    

Loop    

Debug.Print s

End Function

 

 

 

Public Function output(sname)

Range("A" & count).Value = sname

End Function

VBA读取文件

标签:

原文地址:http://www.cnblogs.com/dzh1990/p/4539070.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!