close word > setfocus max access (1 Viewer)

allj

Registered User.
Local time
Today, 04:03
Joined
Sep 4, 2008
Messages
39
Hi
When connecting to a word file using odbc, the word message "opening this document will run ..sql" is hidden from the user. Is there a way to have the messagebox from word popup over access? So far the only way I have been able to view the message is to minimize access - I can do this with code. After the word doc merges to a new doc and is closed, how can I setfocus to access and maximize it again. Any help with this is appreciated. Alan
 

Trevor G

Registered User.
Local time
Today, 12:03
Joined
Oct 1, 2009
Messages
2,341
Alan,

You should be able to use the visible side of the application

Application.Visible = False

so you could switch on and off as you need it.
 

allj

Registered User.
Local time
Today, 04:03
Joined
Sep 4, 2008
Messages
39
Trevor thanks for responding. Ok I minimize access and open word then merge to a new doc .
............
mm.Close SaveChanges:=wdDoNotSaveChanges
Dim acces As Application
Set acces = "c\clinicians mind\database.mdb"

acces.Visible = True
End If

This doesn't work. Any suggestions are appreciated Alan
 

SOS

Registered Lunatic
Local time
Today, 04:03
Joined
Aug 27, 2008
Messages
3,514
Is this code in the same database that you have here:
Set acces = "c\clinicians mind\database.mdb"

If so, you just need to do what Trevor suggested:

Application.Visible = False

no need for any other code. In fact, get rid of:

Dim acces As Application
Set acces = "c\clinicians mind\database.mdb"

acces.Visible = True
End If
and substitute this in its place:
Code:
Application.Visible = False

But then you'll need to make it visible again when you are done.
 

allj

Registered User.
Local time
Today, 04:03
Joined
Sep 4, 2008
Messages
39
maybe I'm not clear or maybe don't get it. I am opening a word doc from access using odbc. however, access has the focus so the message ... to use the sql datasource" isn't visible unless I minimize access. If I use code to minimize access the messagebox has the focus> click ok and open merged doc. Code in this word doc merges to a new doc. When I close the word doc the access doc is now minimized. I need it to be maximized. I tried to put some code in the merged doc to open msaccess maximized but haven't been able to. Does this make sense or am I missing something obvious. Thanks Alan
 

SOS

Registered Lunatic
Local time
Today, 04:03
Joined
Aug 27, 2008
Messages
3,514
If they are not connected by one opening the other to start with then there is no easy way to do it. What I mean, is if you opened your Word Doc from Access where it had a handle on it like:

Code:
Dim wdApp As Word.Application
 
set wdApp = New Word.Application
And then you open it with wdApp and do stuff and then after you are done then you can use wdApp.Quit

and then set the code for Access, then you can do it. Otherwise they are mutually exclusive things if you just use Shell, or some other method, to open the Word document.
 

allj

Registered User.
Local time
Today, 04:03
Joined
Sep 4, 2008
Messages
39
I use the following to open word doc
Set objWord = GetObject(str)
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource.......
i tried this in the open event (nothing happened) after merging to a new doc and also in the close event where I got an error
Shell "C:\clinicians mind\cliniciansmindams.mdb", vbMaximizedFocus
 

Users who are viewing this thread

Top Bottom