Workbooks.Open编译错误

时间:2016-06-30 19:47:37

标签: vba excel-vba excel-2010 excel

我正在尝试使用Microsoft Excel VBA 2010中的Workbooks.Open方法,并且我收到一条编译错误,指出它正在等待" ="。我输错了代码吗?

Workbooks.Open ( _
    Filename:= FromBook, _
    UpdateLinks:= xlUpdateLinksNever, _
    ReadOnly:= False, _
    Format:= 5, _
    Password:= "", _
    WriteResPassword:= "", _
    IgnoreReadOnlyRecommended:= "", _
    Origin:= "", _
    Delimiter:= "", _
    Editable:= "", _
    Notify:= "", _
    Converter:= "", _
    AddToMru:= "", _
    Local:= "", _
    CorruptLoad:= xlNormalLoad)

1 个答案:

答案 0 :(得分:3)

这种方式是期望将值分配给变量IE:

Dim myWB as Workbook

Set myWB = Workbooks.Open ( _
    Filename:= FromBook, _
    UpdateLinks:= xlUpdateLinksNever, _
    ReadOnly:= False, _
    Format:= 5, _
    Password:= "", _
    WriteResPassword:= "", _
    IgnoreReadOnlyRecommended:= "", _
    Origin:= "", _
    Delimiter:= "", _
    Editable:= "", _
    Notify:= "", _
    Converter:= "", _
    AddToMru:= "", _
    Local:= "", _
    CorruptLoad:= xlNormalLoad)

如果你真的不需要这样,你可以拨打电话:

Call Workbooks.Open ( _
        Filename:= FromBook, _
        UpdateLinks:= xlUpdateLinksNever, _
        ReadOnly:= False, _
        Format:= 5, _
        Password:= "", _
        WriteResPassword:= "", _
        IgnoreReadOnlyRecommended:= "", _
        Origin:= "", _
        Delimiter:= "", _
        Editable:= "", _
        Notify:= "", _
        Converter:= "", _
        AddToMru:= "", _
        Local:= "", _
        CorruptLoad:= xlNormalLoad)