简体   繁体   中英

Workbooks.Open Compile Error

I am trying to use the Workbooks.Open Method within Microsoft Excel VBA 2010 and I am receiving a Compile error stating that it is expecting "=". Have I mistyped the code?

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

That way is expecting the value to be assigned to a variable 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)

If you don't really need it that way, you may do a call instead:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM