-1

Excel 97 で fileconv.xla アドインを実行すると、ByRef 引数の型が一致しません。

これが必要な理由は、約 100 個の Lotus 1-2-3 ファイルを wk* から xls に変換する必要があるためです。

コンパイル時に VBA で強調表示された用語は、分離されたコードで二重のアスタリスクでマークされています。

Workbooks.Open Filename:=PathFile(**p_FileInfo**(i, 3), p_FileInfo(i, 4)), ReadOnly:=True, Password:="password"
Sub FinishSub()


Dim TestOpen As Boolean
Dim DirDest As String

Application.ScreenUpdating = False
CreateDir "wzkfpbdxwzkfpbdxwzkfpbdx"
If Not (DirCreated) Then
    Application.ScreenUpdating = True
    Exit Sub
End If

If Len(dlg.DropDowns("DriveDD").List(dlg.DropDowns("DriveDD").ListIndex)) <> 2 Then
    DirDest = Right(dlg.DropDowns("DriveDD").List(dlg.DropDowns("DriveDD").ListIndex), _
                Len(dlg.DropDowns("DriveDD").List(dlg.DropDowns("DriveDD").ListIndex)) - 3) & _
                Right(FullPath, Len(FullPath) - 2)
Else
    DirDest = dlg.DropDowns("DriveDD").List(dlg.DropDowns("DriveDD").ListIndex) & _
                Right(FullPath, Len(FullPath) - 2)
End If

Set wbResult = Workbooks.Add
ActiveCell.Value = LookupString("File")
Range("B1").Value = LookupString("ConvertedTo")
Range("C1").Value = LookupString("Result")
Range("D1").Value = LookupString("Reason")
Range("A2").Select

k = 0
For i = 1 To CountFile
    p_FileInfo(i, 5) = DirDest
    If p_FileInfo(i, 7) = "yes" Then
        k = k + 1
        On Error GoTo ErrorOpen
            Success = "True"
            ErrorMsg = ""
            SetWaitCursor True
            If TestIfWorkbookIsOpen(p_FileInfo(i, 4)) Then Workbooks(p_FileInfo(i, 4)).Close saveChanges:=False
            Application.StatusBar = LookupString("Opening") & p_FileInfo(i, 4) & "(" & k & "/" & CountFileToConvert & ")"
            Application.DisplayAlerts = False


            Workbooks.Open Filename:=PathFile(**p_FileInfo**(i, 3), p_FileInfo(i, 4)), ReadOnly:=True, Password:="password"



        On Error GoTo 0
        On Error Resume Next
            Application.StatusBar = LookupString("Saving") & p_FileInfo(i, 6) & "(" & k & "/" & CountFileToConvert & ")"
            ' Check if the XLS filename already exists.
            FindFileName
            Workbooks(p_FileInfo(i, 4)).SaveAs Filename:=PathFile(p_FileInfo(i, 5), p_FileInfo(i, 6)), FileFormat:=xlNormal
            'Application.StatusBar = False
            Workbooks(p_FileInfo(i, 4)).Close saveChanges:=False
            Workbooks(p_FileInfo(i, 6)).Close saveChanges:=False
            SaveIsSuccess Success
            SetWaitCursor False
        On Error GoTo 0
    End If
Next i
SaveIsSuccess "End"
Application.StatusBar = False
Application.ScreenUpdating = True
Exit Sub

ErrorOpen:   ' Error-handling routine.
Select Case Err ' Evaluate Error Number.
    Case 18
        TestMsgBox = MsgBox(LookupString("UserInterruption", "AlertTable"), vbYesNo)
        If TestMsgBox = vbYes Then
            On Error Resume Next
                Application.StatusBar = False
                Workbooks(p_FileInfo(i, 4)).Close saveChanges:=False
                Workbooks(p_FileInfo(i, 6)).Close saveChanges:=False
                Application.ScreenUpdating = True
                Exit Sub
            On Error GoTo 0
        Else
            Resume Next
        End If
    Case 1004
        SetWaitCursor False
        Set dlg = ThisWorkbook.DialogSheets("Password")
        dlg.DialogFrame.Characters.Text = p_FileInfo(i, 4)
        If TryAgain = False Then
            dlg.TextBoxes("PassTB").Text = LookupString("IsProtected", "AlertTable")
            dlg.EditBoxes("PassEB").Text = ""
        Else
            dlg.TextBoxes("PassTB").Text = LookupString("InvalidPassword", "AlertTable")
        End If
        ShowTest = dlg.Show
        Select Case ShowTest
            Case True
                Resume
            Case False
                Success = "False"
                ErrorMsg = Error()
                Resume Next
        End Select
        SetWaitCursor True
        End Select
  Application.StatusBar = False
End Sub
4

1 に答える 1

0

私はあなたがこれを持っていると仮定します

Public Function PathFile(ByRef a As String, ByRef b As String)
PathFile = "C:\Bla.txt"
End Function

そしてp_FileInfo配列であるため、この場合、次のように関数を呼び出す必要があります。

Workbooks.Open Filename:=PathFile(CStr(p_FileInfo(i, 3)), CStr(p_FileInfo(i, 4))), ReadOnly:=True, Password:="password"

私があなたの質問を誤解していなければ、それはうまくいくはずです。

于 2013-06-27T15:12:16.273 に答える