0

これが機能しない理由を誰でも説明できますか?次のようなエラーがスローされます:

行: 14 文字: 1 エラー: 必要なオブジェクト:'[文字列: "H:\VBS"]' コード: 800A01A8

Const xlDelimited = 1
Const xlNormal = -4143 

Set Excel = CreateObject("Excel.Application")
Set fso = CreateObject("Scripting.FileSystemObject")

Dim Excel
dim objShell
dim objFolder
Dim fileLocation

set objShell = CreateObject("shell.application")
set objFolder = objshell.BrowseForFolder(0, "Select File Location", 1, "H:\")
set fileLocation = CStr(objFolder.self.path)

Set Excel = CreateObject("Excel.Application")
Set fso = CreateObject("Scripting.FileSystemObject")

folderDestination = InputBox("Enter Move to folder")
For Each f In fso.GetFolder(fileLocation).Files
  If LCase(fso.GetExtensionName(f)) = "csv" Then
        .Workbooks.Open
    .Sheets(1).Columns("A").TextToColumns .Range("A1"), xlDelimited,,,,,,,True,"|"
    .ActiveWorkbook.SaveAs .ActiveWorkbook.Path & "\1.xls", xlNormal
    .Quit
  End If
Next

控えめに言ってもかなり混乱しています:S もう一度助けていただければ幸いです!

4

2 に答える 2

0

これを試して:

Const xlDelimited = 1

Const xlNormal = -4143 


Set Excel = CreateObject("Excel.Application")

Set fso = CreateObject("Scripting.FileSystemObject")


Dim Excel

dim objShell

dim objFolder

Dim fileLocation


set objShell = CreateObject("shell.application")

set objFolder = objshell.BrowseForFolder(0, "Select File Location", 1, "H:\")

set fileLocation = fso.GetFolder(objFolder.self.path)

Set Excel = CreateObject("Excel.Application")

Set fso = CreateObject("Scripting.FileSystemObject")

folderDestination = InputBox("Enter Move to folder")

For Each f In fso.GetFolder(fileLocation).Files

  If LCase(fso.GetExtensionName(f)) = "csv" Then

        .Workbooks.Open

    .Sheets(1).Columns("A").TextToColumns .Range("A1"), xlDelimited,,,,,,,True,"|"

    .ActiveWorkbook.SaveAs .ActiveWorkbook.Path & "\1.xls", xlNormal

    .Quit

  End If

Next
于 2013-08-12T14:40:34.577 に答える