Open specific Excel workbook tab with VBA & AHK commands

Posted on 2011-05-11
Last Modified: 2012-05-11
Note:  This question relates to both Excel VBA code and AutoHotKey (AHK) code.  However, I don't know if familiarity with the latter is necessary to provide a solution.


I have got several VBA macros in Excel (2007) which are set up to activate various AHK commands.  

For example, this VBA code:
Sub Main_363_()
Shell ("c:\program files (x86)\autohotkey\autohotkey.exe
C:\Users\SEB\Documents\AHK_Excel\ExcelMacroScripts.ahk param363")
End Sub

Open in new window

launches this AHK command:
If 1 = param363	;Main_363_		
SetTitleMatchMode, 2
WinActivate, Main

Open in new window

which simply opens the specified Excel workbook.

How could either or both of these codes be modified so that instead of just opening the workbook to whichever worksheet happened to last be used, as is the case now, the code will open to a specific worksheet tab within the workbook ?

Question by:Steve_Brady
    LVL 85

    Accepted Solution

    As a matter of interest, why do you need to invoke AHK if you are already using VBA? Why not just open the workbook in code and activate whatever sheet you want?

    Author Comment

    Thanks for the response.  I'm sorry for taking so long to get back to your question.

    The answer is that I already have several AHK macros which run various commands involving both Excel and non-Excel applications.  Some triggers for these are hotkeys and others are GUI buttons but all were created using AHK.  Now I've got the need to write some macros which utilize non-Excel apps but also require access to specific Excel worksheet tabs rather than just workbooks.  Plus, I want the options of including the macro triggers as part of my existing set of hotkeys or as new GUI buttons.

    Note:  because this question has expired, I am going to award points and open it anew.  Thanks again.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
    This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
    The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
    The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now