We help IT Professionals succeed at work.

Running a sub in a sub

Seamus2626
Seamus2626 used Ask the Experts™
on
Hi,

I have some code that opens another workbook. That workbook has code that activates on workbook opening.

The code from my original module stops once the code from the second workbook finishes running

How can i get my original code to resume?

Thanks
Seamus
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Martin Liss"There is still no cure for the common birthday." ~John Glenn
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Please show the code from the first workbook.

Author

Commented:
The problem arises when

Cognos Cash Nostro.xls opens. This has the code inside thisworkbook

Thanks
Seamus






Sub Increment()

'This has been written by Seamus on the 15/06/2011
'Points to note:

'(1) Due to the use of activate next window, it is important  to run this code with no other windows open
'(2) The locations for all of the below files are:

' - G:\Asset Services Risk Team\KRI Raw Data
' - G:\Asset Services Risk Team\Month End KRI Data


'This Sub brings in the file with throughput/brightlines etc


Dim PctDone                 As Single
Dim x                       As Long

x = 1

Application.DisplayAlerts = False

Application.ScreenUpdating = False





Call BringInRawData

'These spreadsheets are opened to ensure links are updated for Cash/Merit and TLM

Application.DisplayAlerts = False

Application.ScreenUpdating = False
   
    Workbooks.Open Filename:= _
        "G:\Asset Services Risk Team\KRI Raw Data\Cognos Cash Nostro.xls"
       
        Windows("Cash Nostro.xls").Activate
       
              ActiveWorkbook.UpdateLink Name:= _
        "H:\Asset Services Risk Team\KRI Raw Data\Cognos Cash Nostro.xls", Type:=xlExcelLinks
     
   
     ActiveWindow.Close
       
        Windows("Update File.xls").Activate
           
         

       
Application.DisplayAlerts = False

Application.ScreenUpdating = False
       
       
   'BringinAgeAnlaysis
       
       
     
            Workbooks.Open Filename:= _
        "G:\Asset Services Risk Team\KRI Raw Data\Merit.xls"
       
        Windows("Merit.xls").Activate
               
        Sheets("Month End").Visible = True
        Sheets("Month End").Select
   
        With ActiveSheet
       
etc etc
"There is still no cure for the common birthday." ~John Glenn
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
What happens if you remove the ActiveWindow.Close line?

Author

Commented:
Perfect, thats the problem, i can close the file afterwards

Cheers,
Seamus