View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
hnyb1 hnyb1 is offline
external usenet poster
 
Posts: 29
Default updating links in a macro

Hi. I'm attempting to write a basic macro that imports from an excel file
(called template) information into a spreadsheet. Once imported, I need to
copy and paste that information in as values, so that they don't change once
the template file changes. This is all working o.k., except that it appears
that the copy and paste as values is happening before all the links are
finished updating, so sometimes the last couple of cells show #REF#. This is
especially true if the template file is not open when the macro is running,
but also sometimes happening even if it is open. Can anyone suggest code to
ensure all links have finished updating before progressing with the macro.
See example code below.

There is a whole row of cells that have formulas like the one below entered
in...
ActiveCell.Formula = "=[Template.xls]Process Evaluation'!$L$9"
ActiveWorkbook.UpdateLink , xlLinkTypeOLELinks
ActiveWorkbook.Save
Range(Selection, Cells(ActiveCell.Row, 1)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Selection.Cells(ActiveCell.Row, 1).Select
Application.CutCopyMode = False

I have Excel 2003 on Windows XP. Thanks in advance!