Solved

Add extra step to current macro to auto update

Posted on 2013-01-23
5
302 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 34

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 34

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

740 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