Solved

VBA - bypass the link update dialog box for the source file

Posted on 2011-09-28
12
211 Views
Last Modified: 2012-05-12
Hi,

I am copy some data from another workbook which apparently have links to another source. When I try to open this file (as usual) excel asks me to confirm wether or not I want to update the link.
Although user can simply say yes or no but i was wondering if its possible to by pass this one by saying 'dont update' -> for the links
Such that its not displayed to the user.  
Current status is,
   Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    Application.Calculation = xlCalculationManual

I though it might help but it doesnt seem to work over the update link pop-up
It would be great if some one could post couple of lines required to achieve it.

Many thanks
0
Comment
Question by:SameerMirza
[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
  • 6
  • 4
  • 2
12 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 400 total points
ID: 36717575
In the workbooks.Open method, specify updatelinks:=False
0
 
LVL 17

Assisted Solution

by:andrewssd3
andrewssd3 earned 100 total points
ID: 36717589
The second parameter of the Workbooks.Open method tells it whether to update links or not (True/False) - I think setting this to False should get rid of your message
0
 
LVL 17

Expert Comment

by:andrewssd3
ID: 36717594
Like he just said...
0
Independent Software Vendors: 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!

 

Author Comment

by:SameerMirza
ID: 36717936
Thanks.
Can any one please tell me what the below code is doing and whats the first argument of GetOpenFileName()

where its defined as
Public Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
    "GetOpenFileNameA" (pOpenFileName As OPENFILENAME) As Long
Sub test(sWks As String, sLoc As String)
    
    Dim OpenFile As OPENFILENAME
    Dim lReturn As Long
    Dim FileDir As String
    Dim FilePos As Long
    Dim PrevFilePos As Long
    Dim oWks As Worksheet

    On Error GoTo Data_Err

    Set oWks = Worksheets(sWks)

    With OpenFile
        .lStructSize = Len(OpenFile)
        .hwndOwner = 0
        .hInstance = 0
        .lpstrFilter = "Excel Files" + Chr(0) + "*.xls" + _
            Chr(0) + "All Files (*.*)" + Chr(0) + "*.*" + Chr(0) + Chr(0)
        .nFilterIndex = 1
        .lpstrFile = String(4096, 0)
        .nMaxFile = Len(.lpstrFile) - 1
        .lpstrFileTitle = .lpstrFile
        .nMaxFileTitle = .nMaxFile
        .lpstrTitle = "Oil Index D-1 File"
        .flags = OFN_HIDEREADONLY + _
            OFN_PATHMUSTEXIST + _
            OFN_FILEMUSTEXIST + _
            OFN_ALLOWMULTISELECT + _
            OFN_EXPLORER
        lReturn = GetOpenFileName(OpenFile)

Open in new window

0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 36717961
That's a completely different question!

It's an API function for getting a filename to open. The argument is a specific Type expected by the function - you should have it declared at the top of the module.
0
 

Author Comment

by:SameerMirza
ID: 36813577
Yes rorya
I understand that its different from the title but its basically this function that we are using to open the file. :)
I dont mind opening another thred for it as long as some one can help me out with it.
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 36813587
Why are you using API functions just to open a file? You can use Application.GetOpenFilename and then Workbooks.Open and then all your problems are solved with about 3 lines of code. :)
0
 

Author Comment

by:SameerMirza
ID: 36813657
It would helpful if you could confirm if takes a dir as a parameter.
That is by default would it go to the folder that I would pass in?

All I want to do is to let user pick a file from a default dir.
If this isnt the required function then it would be great if you could let me know which function can I use


thanks
0
 

Author Comment

by:SameerMirza
ID: 36813709
ok guys sorry for being so annoying.
At the end you have to you workbook.open to open the file :)
and its just second paramter that you have to turn off - updatelink:= false
0
 

Author Closing Comment

by:SameerMirza
ID: 36813715
thanks and appologies for being so annoying :)
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 36813732
Yes, GetOpenFilename allows you to specify a full default path. :)
0
 

Author Comment

by:SameerMirza
ID: 36813778
Well in this case this API function is doing something like,
go to the default folder - (input parameter),
I guess its digging down to the currently updated folder ,
get the file picked up by the user and set some properties for 'OPENFILENAME' (object?)

its actually intresting.
I am not sure if I am interpreting it right but this is what it seems to be doing
I might open another thred just to get understanding of
OPENFILENAME - I guess its object
and function as given about - code section
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

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
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 how to use a scrolling table in Microsoft Excel using the INDEX function.

756 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