Consulting

Results 1 to 5 of 5

Thread: Solved: Cannot switch to an active excel workbook from word

  1. #1
    VBAX Newbie
    Joined
    Jul 2011
    Posts
    4
    Location

    Question Solved: Cannot switch to an active excel workbook from word

    Hi,
    From a word macro, how can I switch to an excel workbook that is already open to run an excel macro within it?

    Any examples online of working with excel through word show the need to open a new instance of excel and open the file in order to have access to it. I would like to avoid this as it takes a long time to open the workbook. And if this cannot be answered, then how could I switch to a specific document in word that is currently open through word vba?

  2. #2
    VBAX Expert CatDaddy's Avatar
    Joined
    Jun 2011
    Posts
    581
    Location
    Me.Application.Workbooks.Open("C:\YourPath\YourWorkbook.xls")

    there is a separate forum for word, but i think its Windows(DocumentName).Activate?
    ------------------------------------------------
    Happy Coding my friends

  3. #3
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    Assuming you know the path of the workbook in question, you can use GetObject:
    GetObject("C:\PathToFile\Workbook.xls").Application.Run "macroname"
    for example.

  4. #4
    VBAX Newbie
    Joined
    Jul 2011
    Posts
    4
    Location
    thank you both for your responses.

  5. #5
    VBAX Expert CatDaddy's Avatar
    Joined
    Jun 2011
    Posts
    581
    Location
    which worked?
    ------------------------------------------------
    Happy Coding my friends

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •