Solved

Excel VBA: Closing Message Box Automatically in

Posted on 2011-02-22
4
932 Views
Last Modified: 2012-06-27
I'm writing a VBA Module in Excel to open other Excel workbooks.  When opening the workbooks I get a couple of message boxes that pop up.  I need to know how to automatically close these message boxes to allow my script to continue mining the data.

If I'm missing some simpler way to mine data from a bunch of workbooks. please let me know.




Here is a snapshot of my code as of now:
Sub MineTimesheets()


SearchPath = "C:\Documents and Settings\USER\Desktop\Time Sheets"


Dim NumWorkbooks As Integer
Dim i As Integer
Dim Data() As String

With Application.FileSearch
    .NewSearch
    .FileType = msoFileTypeExcelWorkbooks
    .LookIn = SearchPath
    .SearchSubFolders = False
    .Execute
    NumWorkbooks = .FoundFiles.Count
End With


For i = 1 To NumWorkbooks
    ReDim Data(1 To i)
    Data(i) = Application.FileSearch.FoundFiles(i)
    Worksheets("Sheet2").Cells(i, 1).Value = Data(i)
Next i


Workbooks.Open ("C:\Documents and Settings\USER\Desktop\Time Sheets\2011-02-16 to 28 Hotchkiss, Caleb.xls")
Application.DisplayAlerts = False
Workbooks(2).Worksheets("Time Sheet").Cells(5, 5).Value = 7
ActiveWorkbook.Close Savechanges:=True
Application.DisplayAlerts = True

End Sub
0
Comment
Question by:sagetechit
  • 3
4 Comments
 
LVL 31

Expert Comment

by:Helen_Feddema
Comment Utility
One possibility is to replace the messge boxes with messages written to the status bar -- no need for any user action.  Here is some code:
Application.DisplayStatusBar = True
Application.StatusBar = "Clearing worksheet rows - Please Wait!"

Open in new window

0
 

Author Comment

by:sagetechit
Comment Utility
The code that Helen Feddema provided still allowed the popups to appear, so it didn't solve my problem.

I did notice that
"Application.DisplayAlerts = False"
prevents one of the popups, but it does not prevent the "This workbook contains links to other data sources. . ." popup.
0
 

Accepted Solution

by:
sagetechit earned 0 total points
Comment Utility
I discovered that the solution is nesting my code in this:

Application.AskToUpdateLinks = False
    MyCode
Application.AskToUpdateLinks = True
0
 

Author Closing Comment

by:sagetechit
Comment Utility
Correct answer.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now