I've been trying to make this work forever.
I want to execute a module in another workbook from the current workbook, wbCntl.
The exactcode works in one application but not in another.
sSignalInProcess and wbSignalInProcess are defined correctly. The idea is to either open or create the sSignalInProcess file on the first pass, then skip that code on subsequent running of its code.
Here's my code:
Sub GetSignalFile()
'Open workbook if signal file is open
On Error Resume Next
Set wbSignalInProcess = Workbooks(sSignalInProcess)
If Err.Number <> 0 Then
Err.Clear
'Open existing signal workbook
On Error Resume Next
Set wbSignalInProcess = Workbooks.Open(sFilePath & sSignalInProcess)
If Err.Number <> 0 Then
Err.Clear
'Copy template signal workbook to a new workbook file for new signal
FileCopy (sStdSignal), (sFilePath & sSignalInProcess)
wbSignalInProcess.Save
'Open new signal workbook
Set wbSignalInProcess = Workbooks.Open(sFilePath & sSignalInProcess)
End If
End If
Err.Clear
Application.Run (wbSignalInProcess.Name & "!MainIntuitor")
wbCntl.Activate
End Sub
The line
Application.Run (wbSignalInProcess.Name & "!MainIntuitor")
is skipped and not executed without an error. Any help would be appreciated.
Grant
I suggest you add
On Error Goto 0
before the critical line. Perhaps you will get a more helpful error message then. By the way, the second
On Error Resume Next
in your code is not necessary - once you activated " Resume Next
", it keeps beeing activated until you leave your Sub or deactivate it with On Error Goto 0
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.