+ Reply to Thread
Results 1 to 2 of 2

Referencing a closed workbook

  1. #1
    Registered User
    Join Date
    11-13-2009
    Location
    Cumbria
    MS-Off Ver
    Excel 2016
    Posts
    87

    Referencing a closed workbook

    Hi Everyone,

    Please can someone tell me what's causing the syntax error when I try and set the string named 'arg' as a reference to cell A1 of a closed workbook?

    Sub Test2()

    Dim arg As String

    'next line is a syntax error

    arg = 'E:\archive\[test.xlsx]Sheet1'! & Range("A1").Range("A1").Address(, , xlR1C1)


    ActiveSheet.Range("A1") = ExecuteExcel4Macro(arg)


    End Sub

    Help much appreciated,

    Thanks,

    Rowan
    Last edited by RowanB; 10-03-2012 at 05:15 AM.

  2. #2
    Registered User
    Join Date
    11-13-2009
    Location
    Cumbria
    MS-Off Ver
    Excel 2016
    Posts
    87

    Re: Referencing a closed workbook

    The following worked:

    Sub Test2()

    Dim arg As String

    arg = "'E:\archive\[test.xlsx]Sheet1'!" & Range("A1").Range("A1").Address(, , xlR1C1)

    ActiveSheet.Range("B1") = ExecuteExcel4Macro(arg)


    End Sub


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1