+ Reply to Thread
Results 1 to 5 of 5

How to access another workbook's ThisWorkbook

  1. #1
    Registered User
    Join Date
    03-23-2016
    Location
    Earth
    MS-Off Ver
    2016
    Posts
    3

    How to access another workbook's ThisWorkbook

    Hello everyone, this is my first post!

    I am trying to make some code to copy a module from my add-in, to the active workbook's ThisWorkbook module. I can't seem to figure out how to access it though. Here's the code I'm using:

    Please Login or Register  to view this content.
    Thanks!

  2. #2
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: How to access another workbook's ThisWorkbook

    Assuming the Target Workbook is being opened by the code, I'd suggest you set an object/workbook variable that refers to it. Then use that workbook variable to full qualify the end point rather than ActiveWorkbook.

  3. #3
    Registered User
    Join Date
    03-23-2016
    Location
    Earth
    MS-Off Ver
    2016
    Posts
    3

    Re: How to access another workbook's ThisWorkbook

    But how would that variable reference its own ThisWorkbook if the code is still being run in the add in? Is there a way to do something along the lines of ActiveWorkbook.ThisWorkbook?

  4. #4
    Registered User
    Join Date
    03-23-2016
    Location
    Earth
    MS-Off Ver
    2016
    Posts
    3

    Re: How to access another workbook's ThisWorkbook

    Quote Originally Posted by InvisibleMan View Post
    Assuming the Target Workbook is being opened by the code, I'd suggest you set an object/workbook variable that refers to it. Then use that workbook variable to full qualify the end point rather than ActiveWorkbook.
    But how would that variable reference its own ThisWorkbook if the code is still being run in the add in? Is there a way to do something along the lines of ActiveWorkbook.ThisWorkbook?

  5. #5
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: How to access another workbook's ThisWorkbook

    ThisWorkbook is always the workbook running the code which, presumably, is the Add-in? The ActiveWorkbook is the workbook that is currently active/selected/in focus/ however you want to describe it. So, no, there isn't a concept of ActiveWorkbook.ThisWorkbook.

    You might, for example, have something like this:

    Please Login or Register  to view this content.

+ 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. Help Copying/transfering Data from one Workbook to ThisWorkbook
    By Jester07 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-17-2014, 01:55 AM
  2. Show One WorkBook while Not showing ThisWorkBook.
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-28-2014, 12:16 PM
  3. Replies: 5
    Last Post: 09-13-2013, 12:03 AM
  4. Access Dynamic Array from ThisWorkBook to Sheet1
    By broro in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-08-2012, 07:04 PM
  5. Copying VBA held in 'ThisWorkbook' to a new workbook
    By goodwinh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-07-2011, 01:52 PM
  6. Copy Thisworkbook code into a new workbook
    By akabraha in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-25-2009, 03:17 PM
  7. [SOLVED] ThisWorkbook.FollowHyperlink to Location in Workbook
    By James Cox in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-25-2005, 11:06 AM

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