By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,299 Members | 1,054 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,299 IT Pros & Developers. It's quick & easy.

FollowHyperlink opens a file, but not visible

P: 7
Access 2010
Full Office 2010 software
Win 7 64 bit

Using the FollowHyperlink method and passing a known/good file path & name, the file opens succsessfully, but in the background, with the database still visible. The user has go to the task bar and manually click the file icon to make it visible. I cannot figure out how to force the file to open visible & on top. The form properties are Popup = True, Modal = False

Here is my code (this code worked fine in previous versions of Access)

Expand|Select|Wrap|Line Numbers
  1. Sub OpenDocument(DocPathName)
  2.  
  3. On Error GoTo errorHandler
  4.  
  5.     'If the document path and name have not been filled in, display this message:
  6.     If IsNull(DocPathName) Then
  7.         MsgBox "You must first enter the document path and file name. Use the Select button to locate and select the file."
  8.       Else
  9.  
  10.         'Now use the path & file name entry and attempt to open the document.
  11.         Application.FollowHyperlink DocPathName
  12.  
  13.     End If
  14.     Exit Sub
  15.  
  16. errorHandler:
  17.     'If the document was not opened using the path as entereed, display this message to the user:
  18.     MsgBox "The document " & DocPathName & " cannot be found. " _
  19.          & "Please check all of the charactures in the path and file name to make sure they are correct."
  20.  
  21. End Sub
May 12 '14 #1
Share this Question
Share on Google+
12 Replies


zmbd
Expert Mod 5K+
P: 5,397
Try changing your current line 11:
Application.FollowHyperlink DocPathName

to:
Expand|Select|Wrap|Line Numbers
  1. Application.FollowHyperlink _
  2.    Address := DocPathName, _
  3.    NewWindow : = true
See if forcing a new window will cause it to open full and on-top.
May 12 '14 #2

P: 7
Thanks for the reply but that does not work. I actually already tried setting the NewWindow property to True. The file still opens, then immediately goes down to the task bar with the database still visible
May 12 '14 #3

zmbd
Expert Mod 5K+
P: 5,397
I think you're going to have to get the application as an object... for example:

>>The following is air code!
if: DocPathName = "C:\ExcelReport.xls"
then:
Expand|Select|Wrap|Line Numbers
  1. Sub OpenDocument(DocPathName) 
  2.  
  3.    On Error GoTo errorHandler 
  4.    Dim xlObj As New Excel.Application
  5.    If IsNull(DocPathName) Then
  6.       MgBox "You must first enter the document" & _
  7.           "path and file name. " & _
  8.           "Use the Select button to locate and" & _
  9.           " select the file." 
  10.       Else 
  11.          Application.FollowHyperlink DocPathName
  12.          Set xlObj = GetObject(, "Excel.Application")
  13.          xlObj.ActiveWindow.WindowState = xlMaximized
  14.    End If 
  15. Exit Sub 
  16. errorHandler: 
  17.    MsgBox "The document " & DocPathName & _
  18.           " cannot be found. " & _
  19.           "Please check all of the charactures" & _
  20.           " in the path and file name to make" & _
  21.           " sure they are correct." 
  22. End Sub 
So, for Line 4 and 12 you'll need for the correct application.
You might find the last example interesting:
Using the CreateObject and GetObject Functions
May 12 '14 #4

P: 7
Let me try that, I'll let you know if it works
May 12 '14 #5

P: 7
Bingo, that fixed it! In my case I used Word.Application, but it now opens with the document on top. If anybody is having that problem, use lines 12 & 13 above, it works!

Thanks zmbd, you da boss
May 12 '14 #6

NeoPa
Expert Mod 15k+
P: 31,768
That will work because (I believe) maximising an application window sets its .Visible property to True automatically.

As standard, when you use CreateObject() (or even when you use GetObject() to open a new window as opposed to a pre-existing one), the .Visible property is False.

To get it to show without making any other changes simply say :
Expand|Select|Wrap|Line Numbers
  1. xlObj.Visible = True.
See Application Automation.
May 12 '14 #7

P: 7
Actually the above fix from zmbd did NOT fix the problem. It looked initially like it did because the Word doc I was trying to open was finally staying on top/visible with the additionas of lines 12 & 13 above. However it turns out that the reason the doc was staying visible is because line 13 was triggering an error - "Runtime error 5853 - Invalid parameter". I tried several things to resolve the error, could not get it resolved. So I just put in an "On Error Resume Next", that got rid of the error message but now the Word doc goes right back to the background/not visible, have to click the icon in the task bar to see it. The only way it stays visible is letting it trigger the above error.

Anybody else have an idea how to resolve this?
May 13 '14 #8

zmbd
Expert Mod 5K+
P: 5,397
As always
We need to have you perform the general troubls shooting first as outlined here:
> Before Posting (VBA or SQL) Code
Once that is done (if possible (^_^)) then follow the instructions there in to post your actual code.

When posting errors:
for each error (if any): the EXACT title, error number, and descriptions that occurred, please do not abreviate nor alter the text,,
and at what line in your posted code the error occurred.
May 13 '14 #9

P: 7
Ok, what the HECK are you talking about? I did not abbreviate anything. And I posted the EXACT title and error number. And I told you the exact line of code it happened on. If you don't want to respond any further with suggestions on how to fix this that's fine, but I am not interested in all of your "rules".

If anybody else has any suggestions on how to resolve this I would appreciate the help.
May 13 '14 #10

zmbd
Expert Mod 5K+
P: 5,397
Ok, what the HECK are you talking about? I did not abbreviate anything. And I posted the EXACT title and error number.
RoyPayne:
There is a nicer way to state that... something like:
""Z, that was the whole error message""
""Z, as far as I know that was the error message""
etc...

The reason I asked for the full text:
Runtime 5853 is not a standard MS Access error
Microsoft Access 2010 Error Numbers and Descriptions Thus, the inquiry to post the exact text.

Oh, and BTW: You might want to read thru all of those errors, there's only about 1300 or so, many of them repeat the text from one to the other with only a word or two variation and yet others, will have %1, %2, %4 and other wildcard replacements available to Office/Access so the numeric can stay the same and the text differ. Sometimes these errors will also appear with a title in the prompt and yet other times the same message will show up in just a message box with an [OK] button and no title nor even a number. All of that information is valuable in trying to determine if ACC, OFF, OS, or what tripped the error.

If you like you can actually build your own local table of Access errors by following the instructions here:
MS KB105666: ACC: How to Find Access Basic Error Codes
Let me know if 5853 shows up in your table... it's not in mine and I have the latest and greatest of the ACC2010 setups. (^_^)


And I told you the exact line of code it happened on.
RoyPayne Post#6 Bingo, that fixed it! In my case I used Word.Application,
And yet you did not post your modified code
Are you still using:
Line13:xlObj.ActiveWindow.WindowState = xlMaximized from the original code I posted. Or did you use the code from the example I pointed out in the link provided in Post#4 along with that posted code?
How am I to know?
Once again, there was a nicer way to provide the information.

(OH, and that line of code may not be the root cause, it could be that we didn't get the correct object in the lines before; however, without your modified code... who's to know?)


If you don't want to respond any further with suggestions on how to fix this that's fine,
That comes across a bit snarky, doesn't it!
I am trying to help you.
The questions asked are in an attempt to understand what is happening.
If you don't want to help us to help you, then that's fine... I have others on the site that I'm trying to help too...

but I am not interested in all of your "rules".
How is it unreasonable to ask you to follow the troubleshooting section of the link given? I can't perform those steps on my PC for you, for one, we don't have the same setup and I don't have your file.
As for the rules contained therein the link provided, I didn't write them, the Senior staff and Site Administrators did; thus, they apply to everyone... including myself, even as a moderator, and you should have read them before making your first post. The rules in that link were not my primary focus though for providing the link, the basic option setup and troubleshooting steps were: (
zmbd:Post9: We need to have you perform the general trouble shooting first as outlined here:
If anybody else has any suggestions on how to resolve this I would appreciate the help.
And NeoPa has already stepped in once as I am sure others will do the same if something jogs their memories about a similar situation. Normally we’re fairly helpful group of people.

RoyPayne: Please keep in mind that moderators, experts, and others are un-paid volunteers that attempt to provide some help and guidance in-between our obligations to work and family – we do not work for you , you do not get to use bad language nor stomp your preverbal feet at us.
May 13 '14 #11

P: 7
Ok. I posted the error message exactly as it appeared.

I will seek help elsewhere. Thanks anyway.
May 13 '14 #12

NeoPa
Expert Mod 15k+
P: 31,768
Just to be absolutely clear for any others that might read this thread and infer that such obnoxious behaviour is tolerated on this site, Roy was given some extra leeway because the person dealing with him is a helper of vast experience and unlikely to be put off by such behaviour (He's a father of young children so used to such).

We do expect site rules to be adhered to, with respect to general manners as well as all the other requirements you sign up for with your membership. It is critically important that any members who spend their time trying to help others can know that they will be protected from any such behaviour, and believe me, they will.

All members can help with this by reporting any such misbehaviour when they see it. We generally find that these are noticed and dealt with before anyone gets a chance to report them, but I assume it's possible for some to be missed sometime, so please report any you see and we'll deal with them appropriately.
May 18 '14 #13

Post your reply

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