+ Reply to Thread
Results 1 to 5 of 5

During VBA switching focus

  1. #1
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    During VBA switching focus

    I have two parts of a macro that I'm trying to get to play nice together. As separate pieces they work but there is a vital link I cannot figure out.

    The full code looks a bit like this..

    Please Login or Register  to view this content.
    So the idea is it opens a file (eventually it will loop), unlocks the VBA. That all works fine. The last bit of code should delete a module from it then re-import it. The problem is that the code seems to operate on My Addins.xlam where it is stored, and I cannot for the life of me work out how to change the focus to the newly opened file. ANy ideas most welcome.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: During VBA switching focus

    Have you tried changing this code so it refers to the workbook you've opened?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331
    Quote Originally Posted by Norie View Post
    Have you tried changing this code so it refers to the workbook you've opened?
    Please Login or Register  to view this content.
    Yup. Tried activating and selecting the named workbbok but neither made any difference at all.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: During VBA switching focus

    On those lines of code why are you using Application instead of xlAp which is the instance of Excel you've opened the workbook in?

    By the way, I wasn't suggesting activating or selecting the workbook, what I was trying to suggest was explicitly referencing the workbook, perhaps using the reference oWb.

  5. #5
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: During VBA switching focus

    I've kind of last track of what I've tried by now tbh. I did try activate / select. Also tried specific referencing but the code won't run. However, I've just tried oWb instead of xlAp and it seems to have worked! You're a lifesaver! Thanks as always.

+ 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. [SOLVED] Worksheet focus problem, how do I set focus?
    By MichiganWilliams in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-19-2014, 03:04 PM
  2. Considering switching to a Mac
    By GlenSydney in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 4
    Last Post: 05-09-2014, 09:03 AM
  3. Switching Ink On or Off
    By ACM2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-04-2010, 05:16 PM
  4. switching last name/first name
    By charlie11k in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-31-2009, 11:13 AM
  5. switching between modes
    By Joe in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-08-2006, 12:00 PM

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