Open Workbook and Duplicate Sheet

Caleeco

Well-known Member
Joined
Jan 9, 2016
Messages
980
Office Version
  1. 2010
Platform
  1. Windows
Hello,

Not sure if im being dim, or this isnt possible. Here is my scenario:
  1. 1 have an active workbook /dashboard (lets call it wb1)
  2. I need to duplicate a sheet from a closed workbook (Lets call it wb2) so that I can process its data
  3. wb2 has macros and a popup message box when opening. Once "ok" is hit on the msgbox, wb2 runs its own update macros
  4. I am trying to copy sheet-Deliverables from wb2 into wb1, but without having to "enable macros" or click "ok" on the message box

Code:
Sub copySheet()
    Dim srcBook As Workbook
    Const fromFile = "\\gbzdrpr-cfs010\SDRIVE\Programme Management\Deliverables\Deliverables Update.xlsm"
    
    With Application
        .DisplayAlerts = False
        .ScreenUpdating = False
        .EnableEvents = False
        .AutomationSecurity = msoAutomationSecurityForceDisable
    End With
    
   Workbooks.Open fromFile, UpdateLinks:=True, ReadOnly:=True, AddToMRU:=False
   Application.EnableEvents = True
   Application.AutomationSecurity = msoAutomationSecurityByUI
   
    Set srcBook = ActiveWorkbook
    srcBook.Sheets("Deliverables").Copy After:=Workbooks("All Commodity SQCD Dashboard.xlsm").Sheets(Workbooks("All Commodity SQCD Dashboard.xlsm").Sheets.Count)
    srcBook.Close False
    
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
End Sub

This is what I have thus far. I dont think wb2 is running its own update macros, but I get this error upon copying the sheet:
4kk4e1.png


Is it a sequence problem?

Any help is appreciated.
Thanks
Caleeco
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,223,711
Messages
6,174,020
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top