+ Reply to Thread
Results 1 to 6 of 6

ThisWorkBook.Path Generates an Error

  1. #1
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Thumbs up ThisWorkBook.Path Generates an Error

    Hi everyone,

    I am using Flash Drive which on my machine is Identified as Drive J. Plug it into another PC and it can be Listed as anything else but J. To extract data from a closed workbook within the same folder I need to make use of ThisWorkBook Path. What I have Is as follows:
    Please Login or Register  to view this content.
    And that works well, as long as "J" does not change. I have tried what I have below, but it does not work. VB tells me "GetRange" Argument is not optional?
    Please Login or Register  to view this content.
    Can someone please help me with this. What must the Code look like to work?

    Thank you.
    Last edited by Winon; 11-22-2011 at 10:43 AM. Reason: Solved with unselfish assistance from great guys!

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: ThisWorkBook.Path Generates an Error

    What's GetRange?

    The drive letter looks to be hard coded, you aren't using thisworkbook

    Please Login or Register  to view this content.
    Last edited by royUK; 11-22-2011 at 09:32 AM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: ThisWorkBook.Path Generates an Error

    Hello Roy,

    Thank you for your interest and help. I must admit, I am totally lost here. I got this code from Ron de Bruin's site and used it as follows and it works.

    Please Login or Register  to view this content.
    This is activated via a CommandButton.

    The GetRange is a Sub which works if I refer to the actual directory only. And that is where my problem is. Should I want to use the Flash Drive on another PC, the Drive name changes, and no extract can be made from the Closed WorkBook.

    The GetRange is:
    Please Login or Register  to view this content.
    Thank You Roy!

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: ThisWorkBook.Path Generates an Error

    Try the the amended code that I posted

  5. #5
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: ThisWorkBook.Path Generates an Error

    Should it not be:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  6. #6
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Thumbs up Re: ThisWorkBook.Path Generates an Error

    Yes Roy,

    I have tried what you gave me, but it did not work. Romperstompers' code did the trick however. What is it, that he knows which we don't?

    Thank you very much Gentlemen.

    Your help is greatly appreciated!!!

+ 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