Open Excel file for reading with VBA without display

Open Excel file for reading with VBA without display

Asked on January 8, 2019 in Excel.
Add Comment


  • 4 Answer(s)

    The best solution is here :

    • In the current excel instance, may be open them invisibly
    • Take cover it and then open the workbooks, however can open a new instance of excel. 
    Dim app as New Excel.Application
    app.Visible = False             //Visible is False by default, so this isn't necessary
    Dim book As Excel.Workbook
    Set book = app.Workbooks.Add(fileName) 
    //  Do what you have to do
    book.Close SaveChanges:=False
    app.Quit
    Set app = Nothing
    
    Answered on January 8, 2019.
    Add Comment

    Try this alternative code :

    Application.ScreenUpdating = False
    
    

    with this code, by using a second instance of Excel, alternatively slowing it down.

    Answered on January 8, 2019.
    Add Comment

    The following code will be explain to open Excel file for reading with VBA without display,

    Application.ScreenUpdating = False
    Workbooks.Open Filename:=FilePath, UpdateLinks:=True, ReadOnly:=True
    ActiveWindow.Visible = False
    ThisWorkbook.Activate
    Application.ScreenUpdating = True
    Answered on January 8, 2019.
    Add Comment

    You can open a new instance of excel though, hide it and then open the workbooks

    Dim app as New Excel.Application
    app.Visible = False 'Visible is False by default, so this isn't necessary
    Dim book As Excel.Workbook
    Set book = app.Workbooks.Add(fileName)
    '
    ' Do what you have to do
    '
    book.Close SaveChanges:=False
    app.Quit
    Set app = Nothing
    Answered on March 5, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.