Activating a tab within a window

Z

Zakynthos

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.
 
R

royUK

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 workshee

Code
-------------------

Dim ws as WorkShee

For Each ws in ThisWorkBook.WorkSheet
'code for workshee
Next w
-------------------

--
royU

Hope that helps.

RoyU
 
J

JLGWhiz

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}
 
Z

Zakynthos

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 b3:p3, 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("b3:p3").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!
 
Z

Zakynthos

Thanks, that's great!

JLGWhiz said:
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}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top