PC Review


Reply
Thread Tools Rate Thread

Code equivalent to Alt + Tab

 
 
=?Utf-8?B?SmltYm9i?=
Guest
Posts: n/a
 
      6th Jul 2007
Is there a programmatical equivalent to Alt + Tab?
I need to switch between 2 open workbooks; 1 has the macro and the other has
all the data, no macros but has a huge variation in file names. It does have
a fixed format (the first sheet is named "Summary", cell A1 is the title
"ClientName") and users need only have the 2 open during execution.

Any clues gratefully received.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlrZSBI?=
Guest
Posts: n/a
 
      6th Jul 2007
You could use Sendkeys which sends keystrokes to another application but it's
not very reliable.

the codes for sendkeys are here.

http://msdn2.microsoft.com/en-us/library/8c6yea83.aspx

Mike

"Jimbob" wrote:

> Is there a programmatical equivalent to Alt + Tab?
> I need to switch between 2 open workbooks; 1 has the macro and the other has
> all the data, no macros but has a huge variation in file names. It does have
> a fixed format (the first sheet is named "Summary", cell A1 is the title
> "ClientName") and users need only have the 2 open during execution.
>
> Any clues gratefully received.

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      6th Jul 2007
Why would the users have to switch back to the workbook with the code?

I would think that they could use Tools|macro|macros (or alt-f8) to run those
macros--and you could even save that workbook with the macros in a hidden state,
so the users don't even know it's there????

======
An alternative???

If you want to give the users a way to access the macros:

For additions to the worksheet menu bar, I really like the way John Walkenbach
does it in his menumaker workbook:
http://j-walk.com/ss/excel/tips/tip53.htm

Here's how I do it when I want a toolbar:
http://www.contextures.com/xlToolbar02.html
(from Debra Dalgleish's site)

I'd even save this macro workbook as an addin (.xla) and then it would be
invisible to the user--except for the toolbar or menu.

Jimbob wrote:
>
> Is there a programmatical equivalent to Alt + Tab?
> I need to switch between 2 open workbooks; 1 has the macro and the other has
> all the data, no macros but has a huge variation in file names. It does have
> a fixed format (the first sheet is named "Summary", cell A1 is the title
> "ClientName") and users need only have the 2 open during execution.
>
> Any clues gratefully received.


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?SmltYm9i?=
Guest
Posts: n/a
 
      6th Jul 2007
Thanks for the response Dave.
Sorry I didn't explain, the workbook with the macros has some look up tables
which are used in the users workbook to calculate some of the results. The
macro switches between them to pick up different sections.
Of course, when I'm recording it, both workbook names are known.

Thanks again. Anymore ideas?

"Dave Peterson" wrote:

> Why would the users have to switch back to the workbook with the code?
>
> I would think that they could use Tools|macro|macros (or alt-f8) to run those
> macros--and you could even save that workbook with the macros in a hidden state,
> so the users don't even know it's there????
>
> ======
> An alternative???
>
> If you want to give the users a way to access the macros:
>
> For additions to the worksheet menu bar, I really like the way John Walkenbach
> does it in his menumaker workbook:
> http://j-walk.com/ss/excel/tips/tip53.htm
>
> Here's how I do it when I want a toolbar:
> http://www.contextures.com/xlToolbar02.html
> (from Debra Dalgleish's site)
>
> I'd even save this macro workbook as an addin (.xla) and then it would be
> invisible to the user--except for the toolbar or menu.
>
> Jimbob wrote:
> >
> > Is there a programmatical equivalent to Alt + Tab?
> > I need to switch between 2 open workbooks; 1 has the macro and the other has
> > all the data, no macros but has a huge variation in file names. It does have
> > a fixed format (the first sheet is named "Summary", cell A1 is the title
> > "ClientName") and users need only have the 2 open during execution.
> >
> > Any clues gratefully received.

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      6th Jul 2007
If you're trying to make entering formulas easier, then you're out of luck.
Macros that do anything won't be running when the user is editing the cell.

But you could use something like:

Option Explicit
Sub testme()

Dim wkbk As Workbook
Dim myWindow As Window
Dim KnownWkbkName As String
Dim FoundIt As Boolean

KnownWkbkName = "Book2.xls"

If SheetExists("summary", ActiveWorkbook) Then
'your in their workbook, so activate the otherone
Workbooks(KnownWkbkName).Activate
Else
FoundIt = False
For Each wkbk In Workbooks
If SheetExists("summary", wkbk) Then
For Each myWindow In wkbk.Windows
If myWindow.Visible = True Then
FoundIt = True
Exit For
End If
Next myWindow
End If
If FoundIt = True Then
Exit For
End If
Next wkbk

If FoundIt = True Then
myWindow.Activate
Else
MsgBox "No other workbook found!"
End If
End If

End Sub
Function SheetExists(SheetName As Variant, _
Optional WhichBook As Workbook) As Boolean
'from Chip Pearson
Dim WB As Workbook
Set WB = IIf(WhichBook Is Nothing, ThisWorkbook, WhichBook)
On Error Resume Next
SheetExists = CBool(Len(WB.Sheets(SheetName).Name) > 0)
End Function



Jimbob wrote:
>
> Thanks for the response Dave.
> Sorry I didn't explain, the workbook with the macros has some look up tables
> which are used in the users workbook to calculate some of the results. The
> macro switches between them to pick up different sections.
> Of course, when I'm recording it, both workbook names are known.
>
> Thanks again. Anymore ideas?
>
> "Dave Peterson" wrote:
>
> > Why would the users have to switch back to the workbook with the code?
> >
> > I would think that they could use Tools|macro|macros (or alt-f8) to run those
> > macros--and you could even save that workbook with the macros in a hidden state,
> > so the users don't even know it's there????
> >
> > ======
> > An alternative???
> >
> > If you want to give the users a way to access the macros:
> >
> > For additions to the worksheet menu bar, I really like the way John Walkenbach
> > does it in his menumaker workbook:
> > http://j-walk.com/ss/excel/tips/tip53.htm
> >
> > Here's how I do it when I want a toolbar:
> > http://www.contextures.com/xlToolbar02.html
> > (from Debra Dalgleish's site)
> >
> > I'd even save this macro workbook as an addin (.xla) and then it would be
> > invisible to the user--except for the toolbar or menu.
> >
> > Jimbob wrote:
> > >
> > > Is there a programmatical equivalent to Alt + Tab?
> > > I need to switch between 2 open workbooks; 1 has the macro and the other has
> > > all the data, no macros but has a huge variation in file names. It does have
> > > a fixed format (the first sheet is named "Summary", cell A1 is the title
> > > "ClientName") and users need only have the 2 open during execution.
> > >
> > > Any clues gratefully received.

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      6th Jul 2007
Ps. If you just want to cycle through the open windows, you can use a macro
with a line like:

ActiveWindow.ActivateNext

(Slightly less code <vbg>)

Dave Peterson wrote:
>

<<snipped>>
--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?SmltYm9i?=
Guest
Posts: n/a
 
      6th Jul 2007
Bravo Mr P. You are my Number 1 Star.
Thank you so much (and far easier than all that mularky earlier!)

"Dave Peterson" wrote:

> Ps. If you just want to cycle through the open windows, you can use a macro
> with a line like:
>
> ActiveWindow.ActivateNext
>
> (Slightly less code <vbg>)
>
> Dave Peterson wrote:
> >

> <<snipped>>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      7th Jul 2007
I don't know. All that malarky did some nice checking.

But glad you have something you can use.

Jimbob wrote:
>
> Bravo Mr P. You are my Number 1 Star.
> Thank you so much (and far easier than all that mularky earlier!)
>
> "Dave Peterson" wrote:
>
> > Ps. If you just want to cycle through the open windows, you can use a macro
> > with a line like:
> >
> > ActiveWindow.ActivateNext
> >
> > (Slightly less code <vbg>)
> >
> > Dave Peterson wrote:
> > >

> > <<snipped>>
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?SmltYm9i?=
Guest
Posts: n/a
 
      10th Jul 2007
My very sincere apologies Dave. I didn't mean to disrespect your elegant code
or your efforts on my behalf. It's just that, being an ignorant sort, I
couldn't understand it at first and your shorter option worked first time.
Now that I've studied your first option, I can see it has some robust
features.

Apologies again and, once again, many many thanks for responding.
Regards
Jimbob

"Dave Peterson" wrote:

> I don't know. All that malarky did some nice checking.
>
> But glad you have something you can use.
>
> Jimbob wrote:
> >
> > Bravo Mr P. You are my Number 1 Star.
> > Thank you so much (and far easier than all that mularky earlier!)
> >
> > "Dave Peterson" wrote:
> >
> > > Ps. If you just want to cycle through the open windows, you can use a macro
> > > with a line like:
> > >
> > > ActiveWindow.ActivateNext
> > >
> > > (Slightly less code <vbg>)
> > >
> > > Dave Peterson wrote:
> > > >
> > > <<snipped>>
> > > --
> > >
> > > Dave Peterson
> > >

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      10th Jul 2007
No apology necessary. I think it just depends on how much "clutter" or extra
stuff you want.



Jimbob wrote:
>
> My very sincere apologies Dave. I didn't mean to disrespect your elegant code
> or your efforts on my behalf. It's just that, being an ignorant sort, I
> couldn't understand it at first and your shorter option worked first time.
> Now that I've studied your first option, I can see it has some robust
> features.
>
> Apologies again and, once again, many many thanks for responding.
> Regards
> Jimbob
>
> "Dave Peterson" wrote:
>
> > I don't know. All that malarky did some nice checking.
> >
> > But glad you have something you can use.
> >
> > Jimbob wrote:
> > >
> > > Bravo Mr P. You are my Number 1 Star.
> > > Thank you so much (and far easier than all that mularky earlier!)
> > >
> > > "Dave Peterson" wrote:
> > >
> > > > Ps. If you just want to cycle through the open windows, you can use a macro
> > > > with a line like:
> > > >
> > > > ActiveWindow.ActivateNext
> > > >
> > > > (Slightly less code <vbg>)
> > > >
> > > > Dave Peterson wrote:
> > > > >
> > > > <<snipped>>
> > > > --
> > > >
> > > > Dave Peterson
> > > >

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: C# equivalent of some SML code Arne Vajhøj Microsoft C# .NET 0 3rd May 2009 09:44 PM
ado.net equivalent of ado code John Microsoft ADO .NET 3 23rd Jul 2008 08:07 PM
C++.NET equivalent code of C#.NET GrayScale code =?Utf-8?B?dGxlbWNlbnZpc2l0?= Microsoft VC .NET 0 29th May 2005 01:04 AM
Re: C# Equivalent of VB.Net Code -- One line of code, simple Ian Microsoft ASP .NET 0 25th Jun 2003 02:14 PM
Re: C# Equivalent of VB.Net Code -- One line of code, simple Ron Microsoft ASP .NET 1 24th Jun 2003 08:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:59 PM.