วันอังคารที่ 30 สิงหาคม พ.ศ. 2565

VBA: เปิดไฟล์ Excel

 VBA: เปิดไฟล์ Excel 

VBA Code


Sub OpenFile()

Dim filter As String

Dim captain As String

Dim customerFilename As String

Dim customerWorkbook As Workbook

'Text file and path

'สามารถกำหนดชนิดของไฟล์ที่ต้องการให้เปิดได้

filter = "Excel files(*.xls),*.xls,Excel files(*.xlsx),*.xlsx,All Files(*.*),*.*"

captain = "Please Select an input file"

customerFilename = Application.GetOpenFilename(filter, , captain)

    If customerFilename = "False" Then

        Exit Sub

    Else

        Sheet1.Range("B5").Value = customerFilename

        Set customerWorkbook = Application.Workbooks.Open(customerFilename)

    End If

End Sub


ตัวอย่าง ===> VBAOpenFiel.xlsm

Good Luck

0 ความคิดเห็น:

แสดงความคิดเห็น

 
Copyright © . DataJeda Computer Basic - Posts · Comments
Theme Template by DataJeda.com · Powered by DataJeda.com