Open excel without update

Vagelisr

New Member
Joined
Sep 22, 2016
Messages
28
Office Version
  1. 2010
  2. 2007
Platform
  1. Windows
Hi to all

I use this code to open multiple Excel files and taske the vaslue of a specific cell
Code:
Function OpenExcelFile(PathFolderName) As String
    Dim XL As Excel.Application
    Dim WBK As Excel.Workbook
    Set XL = CreateObject("Excel.Application")
    Set WBK = XL.Workbooks.Open(PathFolderName)
    OpenExcelFile = WBK.Sheets(TabName).Range(CellName).Value
    WBK.Close False
    Set XL = Nothing
End Function

In one of them it show me the message "This workbook contains links to other data sources"

I'm not sure aboute the message because is in Grrek language.
Did you knou how can i open this excel without show me any messages about update???

Thanks and regards.
 
Greetings,

Is this code housed in an Excel Workbook? If so, I am curious as to why you creating a new instance of the application each time the function is called?

Disregarding that for the moment and more to your question, have you tried including the arguments to open the file read-only and without updating links? Something like:

Rich (BB code):
Function OpenExcelFile(PathFolderName) As String
Dim XL As Excel.Application
Dim WBK As Excel.Workbook


  Set XL = CreateObject("Excel.Application")
  Set WBK = XL.Workbooks.Open(PathFolderName, UpdateLinks:=False, ReadOnly:=True)
  OpenExcelFile = WBK.Sheets(TabName).Range(CellName).Value
  WBK.Saved = True
  WBK.Close False
  Set XL = Nothing
  
End Function

Hope that helps,

Mark
 
Upvote 0
Something like this, note that I've added error handling to ensure alerts are re-enabled. Added lines shown in red

Code:
Function OpenExcelFile(PathFolderName) As String
    Dim XL As Excel.Application
    Dim WBK As Excel.Workbook
[COLOR=#ff0000]On Error GoTo errHandle[/COLOR]
    Set XL = CreateObject("Excel.Application")
[COLOR=#ff0000]    Application.DisplayAlerts = False[/COLOR]
    Set WBK = XL.Workbooks.Open(PathFolderName)
    OpenExcelFile = WBK.Sheets(TabName).Range(CellName).Value
    WBK.Close False
[COLOR=#ff0000]    Application.DisplayAlerts = True[/COLOR]
    Set XL = Nothing
    
Exit Function
[COLOR=#ff0000]errHandle:[/COLOR]
[COLOR=#ff0000]    Application.DisplayAlerts = True[/COLOR]
End Function


Edit: Actually Mark's is a better solution: ^^^^
 
Last edited:
Upvote 0
Thank you very much both of you.
GTO it work like a charm!!!!!!
gallen i haven't add any alerts because i dont need it.
I'm searching in specific folders

Thanksd again
 
Upvote 0
gallen i haven't add any alerts because i dont need it.
Thanksd again

The line Application.EnableAlerts = False prevents any application based popups from showing. It must be used with caution as it will prevent things like prompting to save if you haven't thats why you always re-enable immediately after. I've had to use it a few times especially when opening/closing workbooks in VBA
 
Upvote 0

Forum statistics

Threads
1,226,867
Messages
6,193,426
Members
453,799
Latest member
shanley ducker

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top