返回列表 上一主題 發帖

[發問] 選擇檔案轉成文字檔問題.

[發問] 選擇檔案轉成文字檔問題.

1.選檔[21.XLSX]轉成21.TXT可以,為何選檔[22.XLSX]轉成22.TXT不行,問題在那裡?
2.可否[指定工作表]:
MP1=Range(“B7”)
'With Workbooks.Open(xlsPath, , True).Sheets(MP1)  '如何指定工作表=>不行
With Workbooks.Open(xlsPath, , True).Sheets(1)         '可行.

aaa.rar (39.4 KB)

杜小平

本帖最後由 Andy2483 於 2023-10-30 11:16 編輯

回復 1# dou10801


方法1.:
With Workbooks.Open(xlsPath, , True).Sheets(Val(MP1))
"3"是字串,指定3索引號工作表必須將字串 "3" 轉化為數值 3


方法2.:
宣告為短整數:
    Dim MP1%
    MP1 = Range("B7")
    With Workbooks.Open(xlsPath, , True).Sheets(MP1)
用行動裝置瀏覽論壇學習很方便,謝謝論壇經營團隊
請大家一起上論壇來交流

TOP

回復 2# Andy2483 感謝前輩回覆,21-1.TXT是我須求的完成檔,改With Workbooks.Open(xlsPath, , True).Sheets(Val(MP1))後,產生21.TXT的檔案內容會變成 2.58003E+50
2.58003E+50
2.58003E+50
2.58003E+50
2.58003E+50
2.58003E+50
2.58003E+50
2.58003E+50
2.58003E+50
2.58003E+50

21-1.rar (424 Bytes)

杜小平

TOP

回復 3# dou10801


   
mcs = "'" & mcs1 & Cells(R, MDS2) & Format(Cells(R, MDS3),~~
用行動裝置瀏覽論壇學習很方便,謝謝論壇經營團隊
請大家一起上論壇來交流

TOP

回復 4# Andy2483 會不會是版本問題,我的是2010版,還是不行.
杜小平

TOP

本帖最後由 Andy2483 於 2023-10-30 12:25 編輯

回復 5# dou10801


    選22 結果:


結果不行?還是過程錯誤?
用行動裝置瀏覽論壇學習很方便,謝謝論壇經營團隊
請大家一起上論壇來交流

TOP

回復 6# Andy2483 感謝前輩多次回覆,我產生檔是這樣.

22txt.jpg (24.86 KB)

22txt.jpg

杜小平

TOP

回復 7# dou10801


   
With Workbooks.Open(xlsPath, , True).Sheets(1)
      .Cells.NumberFormatLocal = "@"
      Arr = .[A1].CurrentRegion
      brr = .[A1].CurrentRegion
~~
用行動裝置瀏覽論壇學習很方便,謝謝論壇經營團隊
請大家一起上論壇來交流

TOP

回復 8# Andy2483
With Workbooks.Open(xlsPath, , True).Sheets(1)
      .Cells.NumberFormatLocal = "@"
取第一工作表正常了.


With Workbooks.Open(xlsPath, , True).Sheets(2)    或   With Workbooks.Open(xlsPath, , True).Sheets(val(mp1)
      .Cells.NumberFormatLocal = "@"
這個還是不行...........
杜小平

TOP

回復 9# dou10801


    With Workbooks.Open(xlsPath, , True).Sheets(2) 執行結果 怎樣不行?
用行動裝置瀏覽論壇學習很方便,謝謝論壇經營團隊
請大家一起上論壇來交流

TOP

        靜思自在 : 口說一句好話,如口出蓮花;口說一句壞話如口吐毒蛇。
返回列表 上一主題