0

This is the part of the code

Dim lx_objectExcel As New Excel.Application
Dim lx_wrkBkSrc As Workbook
Dim lx_wrkShSrc  as WorkSheet

'Using lx_objectExcel.Workbooks.Open WORKS but not Workbooks.Open     
'lx_objectExcel.Workbooks.Open(Filename:=lv_path, ReadOnly:=True) 
Set lx_wrkBkSrc  = Workbooks.Open(Filename:=lv_path, ReadOnly:=True)

Using a new instance works

lx_objectExcel.Workbooks.Open(Filename:=lv_shrPath, ReadOnly:=True) 

But Using

Workbooks.Open(Filename:=lv_shrPath, ReadOnly:=True)

the code exits after it opens the file. While debuggig it doesn't go to the next line either; While searching somone had mentioned use "Thisworkbook.Activate", but the code dosen't even enter the next line. The file is of the type ".xlsm" Also Shift is not pressed while opening. I also set application.enableevents to false to prevent any macro from running.

p.s I have asked the question before, but no suitable answer due to my poor questioning

  • Are you running the above code from a module? Also, have you checked what macros/UDF's get triggered in the file you are trying to open? they could be the one causing the problem – Zac Sep 14 '17 at 08:18
  • This is a good answer - https://stackoverflow.com/a/46096253/5448626 – Vityata Sep 14 '17 at 08:18
  • @Zac; there are only some functions not sub in the other xlsm file; I thought Application.EnableEvents prevents running of macros from other files? Doesn't it? –  Sep 14 '17 at 08:27
  • I think @Vityata link should answer your query – Zac Sep 14 '17 at 08:29
  • Oh well!!! I give up... –  Sep 14 '17 at 08:32

0 Answers0