473,465 Members | 1,524 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

FollowHyperlink opens a file, but not visible

7 New Member
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
12 5957
zmbd
5,501 Recognized Expert Moderator Expert
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
RoyPayne
7 New Member
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
5,501 Recognized Expert Moderator Expert
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
RoyPayne
7 New Member
Let me try that, I'll let you know if it works
May 12 '14 #5
RoyPayne
7 New Member
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
32,556 Recognized Expert Moderator MVP
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
RoyPayne
7 New Member
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
5,501 Recognized Expert Moderator Expert
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
RoyPayne
7 New Member
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
5,501 Recognized Expert Moderator Expert
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
RoyPayne
7 New Member
Ok. I posted the error message exactly as it appeared.

I will seek help elsewhere. Thanks anyway.
May 13 '14 #12
NeoPa
32,556 Recognized Expert Moderator MVP
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

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

Similar topics

0
by: John M. Lembo | last post by:
I am using Perl to parse a text file and output to another file. The text file has data on Unix virtual memory (vmstat) and I want to delete lines that I don't want and output lines that I want to...
1
by: Mary Ann | last post by:
I would like to write code in the On Open property of a form that hides the main menu bar toolbar. I have already customized the menu bar to all for showing/hiding but have no clue how to write...
2
by: Colleyville Alan | last post by:
I could not find this in the help file, so here goes... I have some code that opens a word doc which is then set to a variable called Target. Then a FollowHyperlink opens another word doc that...
6
by: Kiran | last post by:
Hi, I have program, which opens file at the startup and logs error messages to the file, file handle is closed at the end of the program. However if file is deleted in-between, program do not...
1
by: lkr | last post by:
hi i got one file transfer program using serialization which has a limitation that i can send only 8192 bytes(8KB). i want to send more than that wht can i do. how can i divide the file into...
1
by: Dsperry101 via AccessMonster.com | last post by:
Hi Everyone, I have a work order database . I am trying to allow user's to attach files to the workorder (ie cad dwq's , text files , pdfs, pictures etc) I have the attachment logic resolved but...
5
by: Piotrekk | last post by:
Hi Having a keyword i need to search HTML file for keyword dismissing all the tags, and checking only plain text. Is there an easy way to do it in C#? Thanks PK
13
by: jhamb | last post by:
Hi, This code is in Perl (just a trial, not tested) to parse a text file and output to another file. It is used to delete lines that are not required and output lines that the user wants, to a new...
185
by: jacob navia | last post by:
Hi We are rewriting the libc for the 64 bit version of lcc-win and we have added a new field in the FILE structure: char *FileName; fopen() will save the file name and an accessor function will...
1
by: maroon halaa | last post by:
Hi all.. my project is in c sharp and must upload pictures to MySql DataBase the uploadfile controle is included in asp form that i made but the problem is that the uploadfile always get...
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
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,...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.