Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
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!

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default updating links in a macro

ActiveWorkbook.Save
should force recalculation (assuming you have not turned recalculation off)
and you should not have any problem...

Try to comment out the Copy/Paste Special code and see whether you get the
errors... I suspect you would.

"hnyb1" wrote:

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!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default updating links in a macro

I verified that I have automatic calculation enabled. I commented out the
copy/paste special code and ran a couple of times. Each time the links would
be added in and would show as #REF even through the save, but would update
moments after completion of the macro.

Does it matter that these workbooks are loaded into a SharePoint site?

"Sheeloo" wrote:

ActiveWorkbook.Save
should force recalculation (assuming you have not turned recalculation off)
and you should not have any problem...

Try to comment out the Copy/Paste Special code and see whether you get the
errors... I suspect you would.

"hnyb1" wrote:

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!

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default updating links in a macro

I don't know enough about SharePoint to say anything...

You may separate the Copy/Paste Special macro and run it after the links
have been updated...

You can also try ActiveSheet.Calculate



"hnyb1" wrote:

I verified that I have automatic calculation enabled. I commented out the
copy/paste special code and ran a couple of times. Each time the links would
be added in and would show as #REF even through the save, but would update
moments after completion of the macro.

Does it matter that these workbooks are loaded into a SharePoint site?

"Sheeloo" wrote:

ActiveWorkbook.Save
should force recalculation (assuming you have not turned recalculation off)
and you should not have any problem...

Try to comment out the Copy/Paste Special code and see whether you get the
errors... I suspect you would.

"hnyb1" wrote:

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!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating links BMA Excel Discussion (Misc queries) 2 July 6th 07 12:46 PM
links not updating? GoBobbyGo Excel Discussion (Misc queries) 7 April 6th 07 12:16 PM
Updating Links WhytheQ Excel Discussion (Misc queries) 7 June 1st 06 11:25 AM
updating links dave glynn Excel Discussion (Misc queries) 1 March 2nd 06 08:28 PM
Updating Links Doug Excel Worksheet Functions 0 February 16th 05 05:21 PM


All times are GMT +1. The time now is 03:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"