Not really much to add to bill's suggestion,but I did notice this:
Quote:
|
Windows("Finder I.xlsm").Activate
|
This is bad practice: try to avoid using anything that selects or gives/requires focus to a specific object. In this case you are activating a excel window specifically, why would you need to?
Ofcourse, it could be that the code inside the excelsheet demands focus because the creator also used the "bad practice" of using selections etc. then you have no choice. But otherwise it should be avoided as much as possible.
What I mean to say is that if the code does not run properly, look in this direction and you are likely to find a cause of your issue. Imagine what would happen when your user would suddenly change focus?
In case you are curious of how to work with objects outside the excel file you are starting in (or anyone who searched for an answer and wound up here), there is a better practice (in my opinion). Rewriting bill's code:
Code:
Sub OpenRunFiles()
Dim sFileName as string
' This is the Workbook object which we will link to the file you want to use
Dim TempWorkbook as Workbook
' sFileName contains the full path to the excel workbook
sFileName = C:\Total Programme\FinderI.xlsm
' Check if Files are open
If WorkbookIsOpen(sFileName) Then
Else
' Open file if not already open, you could hide it from view if you like,
' just look inside the help file
Set TempWorkbook = Workbooks.Open (Filename:=sFileName, ReadOnly:=True, Notify:=False)
End If
' Now you can use the workbook directly, without using any referrals to
' the file itself. So: calling your routine would be:
TempWorkbook.FinderI
' if FinderI is a function that returns a value, you can use the following
' to extract it:
Dim Number as Double
Number = TempWorkbook.FinderI