English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

請問各位達人,C:\data 裡有許多檔案 (如: 123.txt 456.txt 789.txt ......)
用excel要如何一個一個開啟?vb 要如何寫?
感謝您!!!

2006-12-22 10:19:38 · 2 個解答 · 發問者 Boson 3 in 電腦與網際網路 程式設計

2 個解答


'版本VB6.0
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Command1_Click()
Dim S$, Dr$

Dr = "你要開啟的資料夾路徑"
Dr = IIf(Right(Dr, 1) = "\", Dr, Dr & "\") '請將 \ 改成半形
圖片參考:http://tw.yimg.com/i/tw/blog/smiley/15.gif

S = Dir(Dr & "*.xls")

Do Until S = ""
ShellExecute 0, "", Dr & S, "", "", vbNormalFocus
DoEvents
S = Dir
Loop
End Sub

2006-12-22 15:23:51 · answer #1 · answered by W.J.S. 7 · 0 0

功能表設定:
專案->設定引用項目->(勾選)Microsoft Excel 10.0 Object Library

Dim objExcelApp As Excel.Application
Dim objSheet As Excel.Worksheet

Set objExcelApp = CreateObject("Excel.Application")

vPath = App.Path & "\"
objExcelApp.Workbooks.Open vPath & "FNewStuT", , True

Set objSheet = objExcelApp.ActiveWorkbook.ActiveSheet

2006-12-22 15:21:44 · answer #2 · answered by yoo 3 · 0 0

fedest.com, questions and answers