473,396 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Access App / Word Document Focus

I've managed to open a server-stored word document from a button in my Access app. However, even though I code objWord.Visible = True, I cannot make the word document the primary object on the screen (max it out, or set focus to it). The focus remains on the app, and the word document is a tab on the task bar at the bottom. The user can click and open it up, but I want it to automatically be the window in focus when the app opens it.

How do I do that? I've searched all options for the word document in the Access/VBA and can't do it. I would think it would be a easy thing to do.

Chuck C.
May 24 '10 #1
2 4552
ADezii
8,834 Expert 8TB
@chazroma
How about Posting the code that Opens the Word Document? On second thought, I can't see why either approach will not work below:
Expand|Select|Wrap|Line Numbers
  1. Public Sub OpenWordDoc(strDocName As String)
  2. Dim objApp As Object
  3.  
  4. If strDocName = "" Or Dir$(strDocName) = "" Then Exit Sub
  5.  
  6. Set objApp = CreateObject("Word.Application")
  7.  
  8. objApp.Visible = True
  9. objApp.Documents.Open strDocName
  10. End Sub
Expand|Select|Wrap|Line Numbers
  1. Call OpenWordDoc("C:\Test\Doc Files\YaDa - YaDa.doc")
OR
Expand|Select|Wrap|Line Numbers
  1. Public Sub OpenWordDoc_2(strDocName As String)
  2. Dim varRet As Variant
  3.  
  4. 'May need to adjust but this is the Default Location
  5. Const conPATH_TO_Word As String = "C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE"
  6.  
  7. If strDocName = "" Or Dir$(strDocName) = "" Then Exit Sub
  8.  
  9. varRet = Shell(conPATH_TO_Word & " " & Chr$(34) & strDocName & Chr$(34), vbMaximizedFocus)
  10. End Sub
Expand|Select|Wrap|Line Numbers
  1. Call OpenWordDoc_2("C:\Test\Doc Files\YaDa - YaDa.doc")
May 24 '10 #2
Sorry. I've not used this site before.

Here is the code that opens the word document. I want it to be "front" and center after the user clicks on the message box.

***-------------***
Dim objWord As New Word.Application
Dim objWordDoc As Word.Document
If Me.ICP_JH_ExpandedHHC.Value = -1 Then
Set objWordDoc = Nothing 'Initialize Word
Set objWord = Nothing
strTemplate = "\\Pbosbapp01\Apps\RLTC\Intake\Production\Backup\V BA_Code_Files\JHProviderEligibilityIntake52110.doc "
objWord.Visible = True
Set objWordDoc = objWord.Documents.Add(strTemplate)

msg = "Please read the appropriate ICP Guidelines in the Word document" & Chr$(10)
msg = msg & "opened in task list at the bottom of your screen." & Chr$(10) & Chr$(10)
msg = msg & "Re-open Call Log when finished." & Chr$(10) & Chr(10)
msg = msg & "After reading, close this message to continue with Intake." & Chr$(10)
msg = msg & "You may close the Word doc whenever you choose."
retcode = MsgBox(msg, vbInformation + vbOKCancel, "ICP Guidelines")

If retcode = vbCancel Then
msg = "The JH Expanded HHC ICP option box will be deselected and the " & Chr$(10)
msg = msg & "ICP word document closed. Please wait for checkmark deletion."
MsgBox msg, vbInformation, "ICP Guidelines"
ICP_JH_ExpandedHHC.Value = 0
objWordDoc.Close wdDoNotSaveChanges
objWord.Quit
Set objWordDoc = Nothing
Set objWord = Nothing
End If
End If
May 24 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Klein | last post by:
I have an application which can load ms word documents and save them. The application has a main form with a file menu, an edit menu and a tool bar. I have a DocumentControl(usercontrol) defined...
4
by: Jeff Harbin | last post by:
I've got an ACCESS 2000 application that I'm developing. One of the outputs of this app will be to generate a series of 'jobs' which corresponds to a record in the database. Each record will be...
3
by: di | last post by:
I have a Access Database, and I would like to create a word document that (preferable would filter)links to ACCESS table or query. I would like to print the word document on the filtered record...
4
by: Otis Hunter | last post by:
I have been given an Access Database which contains a table that has an OLE object field that contains a Word document. That table contains hundreds of records. I would like to find out how I can...
1
by: svdh | last post by:
I have posed a question last saturday and have advanced alot in the meantime. But I am still not there Problem is that I try to merging various fields from various tables in one document in Word...
4
by: svdh2 | last post by:
Dear All, I have lately strugled more and more with Access, what started as a simple database has brought me to the fundaments of Access. I need to transfer fields from various tables to a...
0
by: LostInMD | last post by:
Hi, I am loading word with vb2005 customized commandbars. During the load of the Word exe, the exe automatically opens a new document. I am having difficulty "activating" the open document...
8
by: babyangel43 | last post by:
Hello, I have a query set up in Access. I run it monthly, changing "date of test". I would like this query to be merged with a Word document so that the cover letter is created in Word, the fields...
1
by: Esther Lane | last post by:
Hello! First off, many many thanks to Albert who wrote the Mail Merge code for MS Access I am using. It has been working beautifully for a few years. However, my client just (without notice!)...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.