Solved

ACCESS 2007 - FOLLOW HYPERLINK PROPERTY - MAKING WORD 2007 THE ACTIVE DOCUMENT

Posted on 2009-04-13
11
1,010 Views
Last Modified: 2013-11-28
I coded hyperlinks to display on an Access 2007 report.  The report lists sequential file identifiers assigned to Word documents. Each file identifier listed in the report is hyperlinked.

By clicking on a hyperlink, the user is taken to the desired Word document.

I wrote the following code to achieve this effect:

Private Sub fldNAME_Click()
Dim strInput As String
strInput = "Y:\SERVERPATH\" & fldNAME & ".doc"
Application.FollowHyperlink strInput, _
NewWindow:=True, AddHistory:=True
End Sub

The links work, and the Word documents open.  Well and good.

The problem is this - once the Word document opens, it immediately minimizes.  That is not good.  I need the Word document to remain the open, visible, and active document until the user decides that she is finished looking at it.

I have tried several different approaches; nothing seems to work.

Thanks for your help.
0
Comment
Question by:AccessHack
  • 7
  • 4
11 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24131019
AccessHack,

1. If you get rid of the NewWindow and AddHistory line, does it work?

2. Consider just opening it using the Shell Command normally without hyperlinking

Something like this:

Dim varApp As Variant
varApp = Shell("C:\Program Files\Microsoft Office\Office12\WINWORD.EXE c:\YourWordFile.doc", vbNormalFocus)

JeffCoachman
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24131428
FWIW,

I use Access 2007 and when I insert a hyperlink to a Word Document, it always opens Full Screen (Maximized)

JeffCoachman
0
 

Author Comment

by:AccessHack
ID: 24131484

boag2000,

Thanks for your input.  

1.  Deleting the NewWindow and AddHistory line of code did not change the outcome.  

2.  In other contexts, I have seen the Shell Function suggested as an option.  II will study it.  I wonder if that will work here, because the underlying data is dynamic; namely, the path to each Word document will be slightly different depending on the "fldNAME" that a user selects in the report.

Q. Brown

0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 125 total points
ID: 24131790
I posted a generic example.

Obviously, you can insert your "fldNAME" variable into the code:

Something *roughly* like this:

Dim varApp As Variant
varApp = Shell("C:\Program Files\Microsoft Office\Office12\WINWORD.EXE c:\" & fldNAME & ".doc", vbNormalFocus)

But, again, I am still curious as to why the hyperlink opens the file minimized.

The Shell proposal is really a workaround.
The bottom line is that the Hyperlink should work.

Let's see if another expert can provide more info...

JeffCoachman
0
 

Author Comment

by:AccessHack
ID: 24131859
boag2000,

I hit upon something that appears to work.  I am posting the code here because I have to think my problem is not the first or last struggle with this issue.  

In my Access database, users open the Word documents from the Access report by clicking on a file identifier located in a field that I will call fldNAME.  

I set the properties of fldNAME so that hyperlinks are displayed on the report.  Users are most comfortable with that "look and feel,"  although technically I believe I am not generating hyperlinks using the code below.

Here is the code I added:

Private Sub fldNAME_Click()

'This code adds hyperlinks to fldNAME in the report that point to
'the WORD DOCS, which open in a new window when a link
'is clicked

Dim strInput As String

strInput = "C:\PATH_NAME\" & fldNAME & ".doc"

Set objWord = CreateObject("Word.Application")

    With objWord
        'Make the application visible.
        .Visible = True

        'Open the document.
        .Documents.Open (strInput)
    End With
End Sub

This coding seems to work well.  Thanks very much for your help, Jeff.

Q. Brown
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24132184
OK,

BTW, please do not use ALL CAPS in your post.
1. It is considered SHOUTING, and by association, ...rude.
2. It does absolutely nothing to draw attention to your post.
We are all mature professionals here, and we read questions based on our interest in them, not on attempts to make the question "Stand Out"

Fair enough?
;-)

JeffCoachman
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24132199
Oh, ...and Welcome to Experts-Exchange.com!

;-)

Jeff
0
 

Author Comment

by:AccessHack
ID: 24132653
Thanks, Jeff.  My apologies for the use of caps.  
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24132925
;-)
0
 

Author Comment

by:AccessHack
ID: 24133305
I wanted to follow up on one thing you noted above.  You wrote:

" . . . I am still curious as to why the hyperlink opens the file minimized."

I researched FollowHyperlink extensively, as well as the various errors I came upon in trying to make FollowHyperlink work for my purposes.

Unfortunately, I could locate no property or method that would directly cause Word to remain the active Window using FollowHyperlink.  I did not find an explanation of the behavior, either.  I, too, remain curious about the reasons for it.

I again thank you very much for your attention to my little puzzle.  I plan to test-drive the Shell Method you suggested; I may decide that I like that better.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24191712
;-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now