Full Version: Returning focus on the Access window
UtterAccess Discussion Forums > Microsoft® Access > Access Automation
StillLearning
Hi everyone!

I searched for posts about returning the focus on the Access window after opening a word doc but I can't seem to find one. I tried this but it doesn't seem to work.

my code would be something like:

CODE
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add(strFilePath & strFileName)
objWord.Visible = True
[color="red"]'Missing line : Return focus to Access window [/color]
DoCmd.SelectObject acReport, strDocName


Any idea ?
freakazeud
Hi,
so you can't just return focus to something within the Access shell?
Have you tried the SetForeGroundWindow API or the SetActiveWindow API? There should be samples for both in the links.
HTH
Good luck
StillLearning
Hi Oliver,

I tried both and it doesn't do anything. I don't understand why...

For now I can use

Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add(strFilePath & strFileName)
objWord.Visible = True'
SendKeys "%{TAB}"
DoCmd.SelectObject acReport, strDocName

but I'd like to have a better solution.

Thanks again! I'll keep trying your examples...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.