Solved

Add extra step to current macro to auto update

Posted on 2013-01-23
5
288 Views
Last Modified: 2013-01-23
Hi Experts

I have the following vba which works perfectly fine...however, when the macro is running it has a intermediate step where the end user has to click the continue button as the following message appears...

This workbook contusions one or more links that cannot be updated

Click continue or edit workbook

I would like to select continue each time and incorporate a step into the current macro to do this automatically if possible



Option Explicit

Sub Conso()
Dim wbDst As Workbook
Dim wbSrc As Workbook
Dim wsSrc As Worksheet
Dim wsDst As Worksheet
Dim rngDst As Range
Dim strFilename As String
Dim strPath As String

    strPath = "C:\Documents and Settings\Test\"
   
    Set wbDst = ThisWorkbook  ' Workbooks.Open("C:\Documents and Settings\Test\Master Template.xls")

    Set wsDst = wbDst.Worksheets("cm1")

    Set rngDst = wsDst.Range("M18")

    strFilename = Dir(strPath & "*.xls")

    While strFilename <> ""

        If strFilename <> wbDst.Name Then

            Set wbSrc = Workbooks.Open(strPath & strFilename)

            Set wsSrc = wbSrc.Worksheets("cm")

            With wsSrc
                .Range("M18", .Range("M" & .Rows.Count).End(xlUp).Offset(0, 31)).Copy rngDst
            End With

            Set rngDst = wsDst.Range("M" & Rows.Count).End(xlUp).Offset(1)

            wbSrc.Close
        End If

        strFilename = Dir()

    Wend

End Sub
0
Comment
Question by:route217
  • 2
  • 2
5 Comments
 
LVL 13

Accepted Solution

by:
Shanan212 earned 250 total points
ID: 38810205
beginning of the macro, add this code

application.displayalerts = false

Open in new window

0
 
LVL 33

Assisted Solution

by:Norie
Norie earned 250 total points
ID: 38810207
You can change this,
Set wbSrc = Workbooks.Open(strPath & strFilename)

Open in new window

to this,
Set wbSrc = Workbooks.Open(strPath & strFilename, UpdateLinks:=3)

Open in new window

and the workbooks should open without a prompt and the links will be updated.
0
 
LVL 13

Expert Comment

by:Shanan212
ID: 38810223
Explanation of my answer:

It says you cannot update links, so regardless of that message and whether you click continue/not, you will not be updating links. This is probably because incorrect references/your source file is corrupted.

Therefore, setting the displayalerts to false will suppress this message.
0
 
LVL 33

Expert Comment

by:Norie
ID: 38810238
route217

Shanan212 has a good point.

I assumed you were just getting the update links message, not the can't update links message.
0
 

Author Comment

by:route217
ID: 38810290
All experts

Firstly thanks for the feedback - the question was to a refer if it appears... Poorly worded in my part - apologies..
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question