PDA

View Full Version : FollowHyperlink ends up in infinite loop



ribe
08-28-2013, 05:16 AM
Hello Everyone,

In Access I'm using the FollowHyperlink command to open an Excel file.
The file opens correctly, but after this Excel seems to get stuck in an infinite loop and I have to use ctrl alt del to force close it.
Any suggestions on how to fix this problem?


Private Sub Command27_Click()
Dim tag As String
tag = Me.Combo2.Column(1)
FollowHyperlink "S:\PSM\Veiligheidskleppen\Non-Critical Valves In Progress\" & tag & "\" & tag & ".xls"
End Sub

Thanks.

SamT
08-28-2013, 08:25 AM
The first thing to do is look at the code in the ThisWorkbook Code Page in the Excel File.

ribe
08-28-2013, 11:26 PM
It seems that there's no code in ThisWorkBook

10520

SamT
08-29-2013, 07:16 AM
Is that the workbook from Me.Combo2.Column(1) ?

If it is, You will probably have to upload it so we can analyze all the Event triggered code in it and find the pieces that causes another Event that causes the first Event.

ribe
08-29-2013, 07:23 AM
Sorry for my ignorance, but Combo2 is on a form in the Access file. After selecting an item in this combo and pushing button Command27, the Excel file belonging to the selected tag is automatically opened. The ThisWorkbook code belongs to the Excel file that is opened by Access.

SamT
08-29-2013, 08:12 AM
With the Workbook, in the VBA Editor, Menu >> Edit >> Find search the Current Project for; partial word, any case, and look for "Change", "Activate", "Close", "Open", and any other Events you can think of. Those are the subs you need to look at.

ribe
08-30-2013, 04:01 AM
I found that a lot of worksheets have a "Change" event. I also found that when I save the Excel file with a worksheet active that does not contain a "Change" event that everything works fine. So, my questions now:

How can I open the Excel file with a specific worksheet?
I also saw that Excel opens with the calculation not at full screen. How can I do this?

Thanks.

SamT
08-30-2013, 10:06 AM
When a Workbook is saved, Excel saves it's complete State.

So..., before closing the book, Activate a safe sheet, Maximize the window and Save.

HiTechCoach
09-03-2013, 07:40 AM
I have found that using ShellExec work better than FollowHyperlink with most apps. I find iit best to only use Followhyperlink with web pages.

See: Start an app with ShellExecute
(http://access.mvps.org/access/api/api0018.htm)

You may need to use Excel Automation to remote control the app. This gives you a lot of control to maximize the Excel app window, selecting worksheets, etc.

See:

http://support.microsoft.com/kb/219151