返回列表 上一主題 發帖

[設一個巨集] 開啟檔案 問題....

[設一個巨集] 開啟檔案 問題....

C:\auto_download_page\chap42589_00001_2013_0830_1457"   =====> file size 70kb
C:\auto_download_page\chap42589_00002_2013_0830_1458"   =====> file size 70kb
C:\auto_download_page\chap42589_00003_2013_0830_1459"   =====> file size 70kb
C:\auto_download_page\chap42589_00004_2013_0830_1500"   =====> file size 70kb
C:\auto_download_page\chap42589_00005_2013_0830_1501"   =====> file size 70kb
C:\auto_download_page\chap42589_00006_2013_0830_1502"   =====> file size 230kb
C:\auto_download_page\chap42589_00007_2013_0830_1503"   =====> file size 230kb
C:\auto_download_page\chap42589_00008_2013_0830_1504"   =====> file size 230kb

請問如果我要設一個巨集 定時開啟檔案
如果 file size 是100kb 以下 就不開啟 ( 循環 N 次 )  ( 並有次序 file名 00001 , 00002 .............. 測試開啟檔案 )
直到檔案 00006 的 size 超過 100kb 才開啟檔案, macro 應該怎寫 ???

回復 2# GBKEE
  1. Set sht1 = Sheets("Sheet1")
  2. Set sht2 = Sheets("Sheet2")
  3. lastrow = sht1.Cells(sht1.Rows.Count, 1).End(xlUp).Row
  4. For rw = 2 To lastrow
  5. With sht2.QueryTables.Add(Connection:= _
  6. "URL;" & sht1.Cells(rw, 1).Value _
  7. , Destination:=Sheets("Sheet2").Range("A1"))
  8. .Name = Sheet
  9. .FieldNames = False
  10. .RowNumbers = False
  11. .FillAdjacentFormulas = False
  12. .PreserveFormatting = False
  13. .RefreshOnFileOpen = False
  14. .BackgroundQuery = False
  15. .RefreshStyle = xlInsertDeleteCells
  16. .SavePassword = False
  17. .SaveData = False
  18. .AdjustColumnWidth = False
  19. .RefreshPeriod = 0
  20. .WebSelectionType = xlEntirePage
  21. .WebFormatting = xlWebFormattingNone
  22. .WebPreFormattedTextToColumns = False
  23. .WebConsecutiveDelimitersAsOne = False
  24. .WebSingleBlockTextImport = False
  25. .WebDisableDateRecognition = False
  26. .Refresh BackgroundQuery:=False
  27. End With
複製代碼
因為我是用web query aspx 來開檔 但不知道要點改

TOP

回復 4# GBKEE

對, 那些檔案是 從下載軟件 download 到電腦 ,
因為經網上 webquerytable取data太慢,
我現在用 cmd.exe >dir /b > filelist.txt paste 在sheet1 A欄裡,
再用A欄裡的path link 順序去取file data  ( 100個file既data 不用2分鐘就RUN完 )
==================================================
我正在探索中 你程式碼 "error 53 file not find "
CreateObject("Scripting.FileSystemObject").GetFile(File_Name)
If UBound(Split(File_Nane, "_")) > 0 Then
還有_ 的意思是否要指定這樣 000000000_00000_0000_0000_0000
因為有4個 _ _ _ _            chap42589_00001_2013_0830_1457
                                   chap42590_00001_2013_0830_1458

現在只差有沒有另類方法可以將 70kb 以下的檔案 (在電腦自動刪除 或者 不會讀取就可以).

TOP

        靜思自在 : 君子為目標,小人為目的。
返回列表 上一主題