VBA Code GetObject & External Links

jstevens
GoldLounger
Posts: 2631
Joined: 26 Jan 2010, 16:31
Location: Southern California

VBA Code GetObject & External Links

Post by jstevens »

I have code that occasionally requests to update external links. Can you recommend a tweak to the code such as UpdateLinks:=False?

I'd prefer not to use Workbooks.Open as I'm working on a closed workbook.

strFile = "C:\myFile.xlsx"
Set sh = GetObject(strFile).Worksheets 'This is the line that occasionally asks to update external links.

Thanks for taking a look,
John
Last edited by jstevens on 18 Apr 2014, 17:07, edited 3 times in total.
Regards,
John

User avatar
HansV
Administrator
Posts: 78601
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: VBA Code GetObject & External Links

Post by HansV »

GetObject doesn't let you control this. You'd have to start an instance of Excel, and open the workbook from within that instance of Excel:

Dim xlApp As Object
Dim xlWbk As Object
Set xlApp = CreateObject(Class:="Excel.Application")
Set xlWbk = xlApp.Workbooks.Open(FileName:="C:\myFile.xlsx", UpdateLinks:=0)
Best wishes,
Hans