+ Reply to Thread
Results 1 to 13 of 13

VBA does not recognize open workbook. Error which emerges is - document is out of range

  1. #1
    Registered User
    Join Date
    02-27-2022
    Location
    Slovenia
    MS-Off Ver
    Office 365
    Posts
    7

    VBA does not recognize open workbook. Error which emerges is - document is out of range

    Dear all,
    I would like to totally automate report which I create every month. So far, I create 2 modules. First module I use to get data from SAP and second module I use to create pivot table and send data to already prepared table. Due to error (out of range) in first module, I have to stop macro and copy paste data manually in file where I run macro. Problem is that VBA does not recognize workbook which I export from SAP. I also read that there could be some issue with Excel instance. I also try with workbook as object but it doesn’t work. I would be very happy if somebody helps me to solve this issue and of course to help others if they have the similar issue. Code is down below and I also mark where issue appear. Kind regards Dean

    Please Login or Register  to view this content.
    Last edited by AliGW; 02-27-2022 at 07:09 AM. Reason: Code tags added.

  2. #2
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,505

    Re: VBA does not recognize open workbook. Error which emerges is - document is out of rang

    Maybe add the extension of the workbook?

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,404

    Re: VBA does not recognize open workbook. Error which emerges is - document is out of rang

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. As you are new here, I have done it for you this time.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  4. #4
    Registered User
    Join Date
    02-27-2022
    Location
    Slovenia
    MS-Off Ver
    Office 365
    Posts
    7

    Re: VBA does not recognize open workbook. Error which emerges is - document is out of rang

    Workbook ("Delovni list v Basis (1)") is SAP report which just pop up when I create report from SAP (i didn't find the way to save it on computer). File doesn't have any extension xls etc. but defenetly it is not csv file. Code work several times but then stop (error out of range). VBA does't recognise workbook in toggle folder and that's why I get error out of range. How can I add extension to file when I can't select it. Is solution in loop through all open workbooks?

  5. #5
    Registered User
    Join Date
    02-27-2022
    Location
    Slovenia
    MS-Off Ver
    Office 365
    Posts
    7

    Re: VBA does not recognize open workbook. Error which emerges is - document is out of rang

    The problem is that when I export file from SAP it is not showed in project explorer (visual basic where I run macro). However I try to loop through open workbooks it doesn't find it. What to do?

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: VBA does not recognize open workbook. Error which emerges is - document is out of rang


    Hi,

    'cause the SAP file is opened in a different Excel session, not the one of your workbook
    so if you know its full path name then try GetObject function as explained in VBA help …

    Or the obvious is to ask on SAP side to just create the file without opening it under Excel …

  7. #7
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,251

    Re: VBA does not recognize open workbook. Error which emerges is - document is out of rang

    Quote Originally Posted by Dejan88 View Post
    ... with Excel instance ...
    You will need to use API to find that instance of excel that has a window called "Delovni list v Basis (1)".
    I once found a very neat Peter Thornton's code that you could use for this. Check if you can handle modifying it:

    https://social.msdn.microsoft.com/Fo...forum=exceldev

  8. #8
    Registered User
    Join Date
    02-27-2022
    Location
    Slovenia
    MS-Off Ver
    Office 365
    Posts
    7

    Re: VBA does not recognize open workbook. Error which emerges is - document is out of rang

    Tnx. I will try.

  9. #9
    Registered User
    Join Date
    02-27-2022
    Location
    Slovenia
    MS-Off Ver
    Office 365
    Posts
    7

    Re: VBA does not recognize open workbook. Error which emerges is - document is out of rang

    Can you help me with instructions how to get full path name?
    Last edited by Dejan88; 03-01-2022 at 01:37 PM. Reason: *

  10. #10
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: VBA does not recognize open workbook. Error which emerges is - document is out of rang

    I suspect your saying the full path name of the current workbook? In the VBE, open the immediate window and type in, ?ActiveWorkbook.FullName
    HTH
    Regards, Jeff

  11. #11
    Registered User
    Join Date
    02-27-2022
    Location
    Slovenia
    MS-Off Ver
    Office 365
    Posts
    7

    Re: VBA does not recognize open workbook. Error which emerges is - document is out of rang

    Tnx. I will try tomorrow at office.

  12. #12
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,251

    Re: VBA does not recognize open workbook. Error which emerges is - document is out of rang

    Quote Originally Posted by Dejan88 View Post
    ... how to get full path name?
    For example: (modifications to Peter Thornton's test procedure for "Path"):
    Please Login or Register  to view this content.
    Full path name - with "FullName" as in info from jeffreybrown.
    Last edited by mjr veverka; 03-01-2022 at 08:36 PM.

  13. #13
    Registered User
    Join Date
    02-27-2022
    Location
    Slovenia
    MS-Off Ver
    Office 365
    Posts
    7

    Re: VBA does not recognize open workbook. Error which emerges is - document is out of rang

    Tnx for help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. error when hiding application while another document open
    By Undo in forum Word Programming / VBA / Macros
    Replies: 5
    Last Post: 11-29-2021, 12:42 PM
  2. [SOLVED] Code Error when another Excel document is open
    By Si-Phy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-04-2017, 09:49 AM
  3. [SOLVED] Update document (Word file) on workbook open
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 11-14-2015, 06:39 AM
  4. open excel source document in background when i open word document
    By hootiebsc in forum Word Programming / VBA / Macros
    Replies: 5
    Last Post: 03-22-2013, 07:50 PM
  5. macro to copy cells(Range) from an open Workbook to another open Workbook.
    By jbester in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-22-2013, 09:47 AM
  6. runtime error recived for some trying to open document
    By webguync in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-26-2009, 05:29 PM
  7. [SOLVED] i cannot open excel file error Cannot access read-only document me
    By Lenda. in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-14-2005, 03:06 PM

Tags for this Thread

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