PC Review


Reply
Thread Tools Rate Thread

Activating a tab within a window

 
 
Zakynthos
Guest
Posts: n/a
 
      5th Nov 2008
Using tab keys I'm unable to 'activate' tabs within my window in a workkforce
management program. I need to do this in order to be able to run data
through to this tab from Excel.

I've written the code the populate each tabbed window separately but would
like to combine the code by activating the next tab and using 'sendkeys' to
send a {RIGHT} to select this next tab.

I've tried many combinations of ctrl/alt/shift/F keys etc without success.
I've also tried tabbing through the fields in the first window but this only
leads me out into the left pane explorer window.

Is there any VB code I could use to activate the second tab in the window?
Or Perhaps a combination of 2 or more keys whicih I could 'send' to the
window?

Many thanks for your help.
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      5th Nov 2008
Ctl + PageDown moves the sheet selection to the right, SendKeys: ^{PGDN}.
Tab key move the cursor or cell outline for the active cell. To select
sheets to the left, use Ctl + PageUp: ^{PGUP}

"Zakynthos" wrote:

> Using tab keys I'm unable to 'activate' tabs within my window in a workkforce
> management program. I need to do this in order to be able to run data
> through to this tab from Excel.
>
> I've written the code the populate each tabbed window separately but would
> like to combine the code by activating the next tab and using 'sendkeys' to
> send a {RIGHT} to select this next tab.
>
> I've tried many combinations of ctrl/alt/shift/F keys etc without success.
> I've also tried tabbing through the fields in the first window but this only
> leads me out into the left pane explorer window.
>
> Is there any VB code I could use to activate the second tab in the window?
> Or Perhaps a combination of 2 or more keys whicih I could 'send' to the
> window?
>
> Many thanks for your help.

 
Reply With Quote
 
Zakynthos
Guest
Posts: n/a
 
      6th Nov 2008
Roy, many thanks you've convinced me it's possible to get my data onto the
next tab and I agree that sendkeys is not the best way to do it - but as my
knowledge of VB is limited it's usually reliable enough for a quick fix to a
problem.

If I have an Excel SS called: Genesys data input.xls and my first set of
data is on a tab called 'contract' in cells a1:k1 and my 2nd set of data is
on a tab called contractavail in cells b33, how would I convert the
sendkeys code I've written below into a VB script that would achieve the same
results in a more reliable way. This would be an invaluable example which I
could build on for future work.

The first tab I'm sending the 'contracts' data to is called ""WFM
Configuration Utility - Contracts" and the code is as follows:

AppActivate "WFM Configuration Utility - Contracts"

With ThisWorkbook.Sheets("contract")
Application.ScreenUpdating = False

SendKeys "{TAB}"

SendKeys .Range("B1").Value

SendKeys "{TAB}"
SendKeys "{TAB}"

SendKeys .Range("c1").Value

SendKeys "{TAB}"
SendKeys .Range("d1").Value

SendKeys "{TAB}"

SendKeys .Range("e1").Value

SendKeys "{TAB}"

SendKeys .Range("f1").Value

SendKeys "{TAB}"

SendKeys .Range("g1").Value

SendKeys "{TAB}"

SendKeys .Range("h1").Value

SendKeys "{TAB}"

SendKeys .Range("i1").Value

SendKeys "{TAB}"
SendKeys "{TAB}"

SendKeys .Range("j1").Value

SendKeys "{TAB}"

SendKeys .Range("k1").Value



Sheets("contract").Select
Range("A1:z1").Select
Selection.Delete Shift:=xlUp 'Application.Run "'Genesys data
input.xls'!gostart"


Sheets("Start").Select

End With


End Sub


The 2nd tab

I've used the following code to activate the 2nd tab that I want to get data
from the contractavail tab in Excel to is activated as a separate routine,
therfore I activate the window again as "WFM Configuration Utility -
Contracts" and use this:


AppActivate "WFM Configuration Utility - Contracts"


With ThisWorkbook.Sheets("contractavail")

Application.ScreenUpdating = False

SendKeys "{TAB}"
SendKeys .Range("c3").Value


SendKeys "{TAB}"
SendKeys .Range("d3").Value

SendKeys "{TAB}"
SendKeys "{TAB}"

SendKeys .Range("e3").Value
SendKeys "{TAB}"
SendKeys .Range("f3").Value

SendKeys "{TAB}"
SendKeys "{TAB}"

SendKeys .Range("g3").Value
SendKeys "{TAB}"
SendKeys .Range("h3").Value

SendKeys "{TAB}"
SendKeys "{TAB}"


SendKeys .Range("i3").Value
SendKeys "{TAB}"
SendKeys .Range("j3").Value

SendKeys "{TAB}"
SendKeys "{TAB}"

SendKeys .Range("k3").Value
SendKeys "{TAB}"
SendKeys .Range("l3").Value

SendKeys "{TAB}"
SendKeys "{TAB}"

SendKeys .Range("m3").Value
SendKeys "{TAB}"
SendKeys .Range("n3").Value

SendKeys "{TAB}"
SendKeys "{TAB}"

SendKeys .Range("o3").Value
SendKeys "{TAB}"
SendKeys .Range("p3").Value



Sheets("contractavail").Select
Range("b33").Select
Selection.Delete Shift:=xlUp '


Sheets("Start").Select


End With

End Sub


I do appreciate this is a very clumsy, long winded and inaccurate way to get
the result I want but it does work so for now I'm reasonably happy but would
like to improve the way I do things!

Any help would be greatly appreciated!



"royUK" wrote:

>
> You don't need to select a sheet to write data to it.
> SendKeys is not a reliable method.
>
> You can use a loop to work with each worksheet
>
> Code:
> --------------------
>
> Dim ws as WorkSheet
>
> For Each ws in ThisWorkBook.WorkSheets
> 'code for worksheet
> Next ws
> --------------------
>
>
> --
> royUK
>
> Hope that helps.
>
> RoyUK
> ------------------------------------------------------------------------
> royUK's Profile: http://www.thecodecage.com/forumz/member.php?userid=15
> View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=25455
>
>

 
Reply With Quote
 
Zakynthos
Guest
Posts: n/a
 
      6th Nov 2008
Thanks, that's great!

"JLGWhiz" wrote:

> Ctl + PageDown moves the sheet selection to the right, SendKeys: ^{PGDN}.
> Tab key move the cursor or cell outline for the active cell. To select
> sheets to the left, use Ctl + PageUp: ^{PGUP}
>
> "Zakynthos" wrote:
>
> > Using tab keys I'm unable to 'activate' tabs within my window in a workkforce
> > management program. I need to do this in order to be able to run data
> > through to this tab from Excel.
> >
> > I've written the code the populate each tabbed window separately but would
> > like to combine the code by activating the next tab and using 'sendkeys' to
> > send a {RIGHT} to select this next tab.
> >
> > I've tried many combinations of ctrl/alt/shift/F keys etc without success.
> > I've also tried tabbing through the fields in the first window but this only
> > leads me out into the left pane explorer window.
> >
> > Is there any VB code I could use to activate the second tab in the window?
> > Or Perhaps a combination of 2 or more keys whicih I could 'send' to the
> > window?
> >
> > Many thanks for your help.

 
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
Help with activating window from Application.GetOpenFilename Curt Microsoft Excel Programming 4 5th May 2010 02:18 PM
Activating EXCEL window from PowerPoint =?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?= Microsoft Excel Programming 0 17th Aug 2007 02:06 AM
Word 2003 slow re-activating its window =?Utf-8?B?UmVkIEtpdGU=?= Microsoft Word Document Management 0 28th Mar 2007 07:24 PM
Grabbing data from diff window w/o activating it McManCSU Microsoft Excel Programming 1 18th Aug 2005 08:44 PM
activating browser window from access Susan Windows XP Internet Explorer 1 12th Sep 2003 10:48 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:45 PM.