Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Add extra step to current macro to auto update

Posted on 2013-01-23
5
Medium Priority
?
313 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 1000 total points
ID: 38810205
beginning of the macro, add this code

application.displayalerts = false

Open in new window

0
 
LVL 35

Assisted Solution

by:Norie
Norie earned 1000 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 35

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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 will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

927 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