Solved

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

Posted on 2011-09-28
12
208 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delete all empty columns using VBA 7 46
Excel Formula to check both condition's and return values 2 35
sort column using vba 2 21
Formula Help 3 24
A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

825 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