update links in excel cause GetObject to fail

  • Thread starter Thread starter Charlie Whitcraft
  • Start date Start date
C

Charlie Whitcraft

Hi all, I hope this is the best place to post.

I have a vb.net2003 program that needs to get 4 cells out of a complex
excel sheet. The code is failing on the GetObject because the sheet
has links in it, and when you open it it asks if you want to update
links. Does anybody know how I can answer this-set a property from
code? When I go into excel and set the properties to don't update
links it works, but I can't do this because I have 1000's of these
sheets(it's part of a complex cost accounting system).

Iam doing

xlApp = GetObject(, "Excel.Application")
With xlApp
.Visible = False
.UserControl = False
.ShowStartupDialog = False
End With

xlFileName = xlFolder & itemNbr & ".xls"
xlBook = GetObject(xlFileName)

xlSheet = xlbook.Worksheets(1)
xlRange = xlSheet.Range("D117")
matlCost = xlRange.Value2

I have tryed
With xlBook
.UpdateLinks = Excel.XlUpdateLinks.xlUpdateLinksNever
End With
after the GetObject but it fails on the GetObject, & you can't put it
before.

Does anybody know how to specify this on the GetObject? or any other
method?

Is there a better place to post this?

Thanks Charlie.
 
Back
Top