+ Reply to Thread
Results 1 to 5 of 5

Run-time error 438 - when controlling Excel remotely

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-13-2009
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    245

    Run-time error 438 - when controlling Excel remotely

    hello, could some one please look at my code and advise on how to fix my excel 2003 run-time error 438 "Object doesn't support this property or method" error? The VBE highlights this line of code:

    Set xlDoc = xlApp.Documents.Open("G:\JOC\HQJOC\J1-4 Support\J1  NWCC\Databases\Finance\NWCC Financial Register - Charts.xls")
    The code below is the entire macro:

    Sub OpenExcelWorkbook()
    'In order to use this code you must set a reference to the
    'Word object library by doing this. In the VB Editor click
    'Tools, References. Then search for Microsoft Excel n.n Object Library
    'where n.n will depend on your version of Excel.
    
    
    
    Dim xlApp As Excel.Application, xlDoc As Excel.Workbook
    
    On Error Resume Next
    
    Application.ScreenUpdating = False
    
    On Error Resume Next
    Set xlApp = GetObject(, "Excel.Application")
    If Err.Number <> 0 Then 'Excel isn't already running
    Set xlApp = CreateObject("Excel.Application")
    End If
    On Error GoTo 0
    
    Set xlDoc = xlApp.Documents.Open("G:\JOC\HQJOC\J1-4 Support\J1  NWCC\Databases\Finance\NWCC Financial Register - Charts.xls")
    xlApp.Visible = True
    
    xlDoc.Activate
    
    End Sub

    Any help on this would be greatly appreciated.

    Kind regards,

    Chris
    Last edited by longbow007; 08-13-2009 at 08:35 PM.

  2. #2
    Forum Contributor
    Join Date
    04-01-2009
    Location
    Irvine, CA
    MS-Off Ver
    Excel 2010
    Posts
    280

    Re: Run-time error 438 - help please

    Excel does not support the Documents (MS Word) command...
    Set xlDoc = xlApp.Documents.Open
    Use Workbooks insteam...
    Set xlDoc = xlApp.Workbooks.Open
    Last edited by Leith Ross; 08-13-2009 at 08:14 PM. Reason: Added Code Tags

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Run-time error 438 - help please

    Hello longbow007,

    Please change your tile to more accurately reflect your question or problem. Refrain from generic titles like "Need Help", "Urgent", "Have Problem", etc.

    A better title would be "Run-time error 438 when controlling Excel remotely"
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Run-time error 438 - help please

    Hello Chances2,

    Please remember to use code tags in the future.

  5. #5
    Forum Contributor
    Join Date
    06-13-2009
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    245

    Re: Run-time error 438 - when controlling Excel remotely

    Thanks Chance2 and Leith Ross for all your help - very much appreciated. Your revised code works well

+ 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