Solved Open a file without moving the focus (1 Viewer)

Sun_Force

Active member
Local time
Today, 09:58
Joined
Aug 29, 2020
Messages
396
I didn't say that the one line solution would affect the focus only that it was far simpler than the code you were working with.
Sorry. My misunderstanding.

Are you sure that copying from the PDF wouldn't be useful to reduce typos?
Yes. Almost everything is selected from combo or list box. Company name, delivery address, etc.
Very few fields are typed. And they are numbers. (Order Quantity etc)

Thanks again for all the time you put on this.
 

Sun_Force

Active member
Local time
Today, 09:58
Joined
Aug 29, 2020
Messages
396
Sure.
But remember, AppActivate may need adjustment on your computer. When I open Excel and a new workbook, I get a window called Book1 - Excel (but maybe you get something different). When I open Notepad, I get a window titled "Untitled - Notepad" (presumably you get the same thing, but maybe you don't).

Here are my results. You can see how effectively one line of code was the key.

View attachment 89620
Million thanks.
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 20:58
Joined
Feb 19, 2002
Messages
42,981
But you never checked moving focus to the current form AFTER the FollowHyperlink????
 

Sun_Force

Active member
Local time
Today, 09:58
Joined
Aug 29, 2020
Messages
396
But you never checked moving focus to the current form AFTER the FollowHyperlink????
I did and I explained it in #3 post on first page.
object.SetFocus in vba acts within the application. When OS has moved the focus to a different window (another application), no matter how many times you change the focus within Access, OS is focused on another application. The active window is newly opened document and not Access. So all key strocks etc goes to that application and not Access.You can test it for yourself and you'll understand what I mean. @arnelgp 's solution works and it makes Access the active window.
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 20:58
Joined
Feb 19, 2002
Messages
42,981
If Arnel's solution worked, you might have mentioned it earlier. As long as you're happy, I'm happy. Sorry to belabor the point.
 

Isaac

Lifelong Learner
Local time
Yesterday, 17:58
Joined
Mar 14, 2017
Messages
8,738
you might have mentioned it earlier.
They did, in post 16.

The only reason I kept going with AppActivate is because when you can do with one line of code that you understand and can maintain instead of 200 that you don't and cannot, that should always be encouraged. :)
 

Users who are viewing this thread

Top Bottom