manual open and workbooks.open macro producing different results

jdubyaIII

New Member
Joined
Oct 12, 2017
Messages
6
Hello,

I have two worksbooks, call them A and B. workbook A references cells in workbook B. When I manually open workbook B, the cells in workbook A update. When I insert code to open workbook B using Workbooks.Open, workbook B does open, but the cells in A do NOT update. I'm at a loss as to what to try. Here is my code:

Private Sub Workbook_Open()
Call ReadDataFromClosedFile
End Sub


Sub ReadDataFromClosedFile()


Application.ScreenUpdating = False

Dim src1 As Workbook

Set src1 = Workbooks.Open(".....", False, False)


End Sub

thank you in advance.

Regards
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Untested, but you can try this modification
Code:
Private Sub Workbook_Open()
    Call ReadDataFromClosedFile
Application.Calculate
End Sub
 
Upvote 0
Have you confirmed that you have installed the workbook_open event macro correctly (goes in a Thisworkbook module, not a standard module), and that you have not inadvertently disabled events?

To check the latter, change the event macro to this:
Code:
Private Sub Workbook_Open()\
MsgBox "Workbook_Open event has fired correctly"
    Call ReadDataFromClosedFile
End Sub
If you don't get a pop-up message when the workbook is first opened, events are disabled.
To enable them:
Open the VBE and press ctrl + g to open the Immediate Window.
In the Immediate Window type (w/o quote marks): "Application.EnableEvents True" and press enter.
Save and close the workbook, then open it again and you should get the pop-up message.
 
Upvote 0
Hi Joe, yes, events are enabled. I was able to solve my problem in a roundabout way by copying the data from workbook B into the workbook A into a new sheet. Then the values I want to update draw from this new sheet. This works.

Private Sub Workbook_Open()
Call ReadDataFromClosedFile
MsgBox "Updated!"
End Sub


Sub ReadDataFromClosedFile()


Application.ScreenUpdating = False

Dim src1 As Workbook
Dim curWorkbook As Workbook

Set curWorkbook = ThisWorkbook
Set src1 = Workbooks.Open("..............", False, False)

curWorkbook.Worksheets("sls").Range("A1:D1000").Formula = src1.Worksheets("Sheet1").Range("A1:D1000").Formula


src1.Close False

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,950
Messages
6,175,584
Members
452,653
Latest member
craigje92

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