Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-28
12
Medium Priority
?
218 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 1600 total points
ID: 36717575
In the workbooks.Open method, specify updatelinks:=False
0
 
LVL 17

Assisted Solution

by:andrewssd3
andrewssd3 earned 400 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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!
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

719 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