Open all files in a folder, no popups wanted

chaostheory

Registered User.
Local time
Today, 00:19
Joined
Sep 30, 2008
Messages
69
I have a very large worksheet that is pulling data from about 3 different data sources. One of the tabs is opening a folder, and opening every file in the folder, delimiting the data, then pulling out the info it needs. The problem is, everytime it delimits the data, it asks if i want to replace the contents of the destination cells, i have to click OK, then it asks if i want to save the document changes when it closes, which i hit no. I need both of those responses to be automatic, as i don't want to click "OK" and "NO" 1000 times for each folder.

Code:
Sub hgDataPoints()
Dim x As Integer
Dim count As Integer
Dim counter As Integer
Dim hgPath As String
Dim ThisWB, DataFile, FolderPath, DataWB
Dim strNum As String
Dim benchNum As String
Dim fileSpec As String
Application.ScreenUpdating = False
    ThisWB = ActiveWorkbook.Name 'this allows you to refer back to the workbook from which you are running the macro (summary workbook)
    DataFile = Application.GetOpenFilename 'allows user to pick file from the folder of interest using a browser and then saves its path\folder\name
    FolderPath = Left(DataFile, InStrRev(DataFile, "\")) 'parses the path\folder\name to get just the path\folder(we are interested in all the files in the folder not just the selected one)
 
    fileSpec = "*.*"
    DataFile = Dir(FolderPath & fileSpec) 'this line and the loop that follows will open up one file at a time from the specified location, extract the desired info, write the info to the summary workbook and then close the file it opened
    Do While DataFile > ""
            Workbooks.Open (DataFile)
                Columns("A:A").Select
[COLOR=red]               Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _[/COLOR]
[COLOR=red]               TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _[/COLOR]
[COLOR=red]               Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _[/COLOR]
[COLOR=red]               :=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _[/COLOR]
[COLOR=red]               Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1)), _[/COLOR]
[COLOR=red]               TrailingMinusNumbers:=True[/COLOR]
                'have it get all the data characteristics (noise, 20%, 80%...) you are interested in and then store these values in variables
                    strNum = Left(Range("d7"), 6)
                    benchNum = Range("G5")
                    sampleID = Range("D7")
                        Range("a150").Select
                        counter = 0
                        For y = 1 To 100
                            If Range("a150").Offset(y, 0) <> "" Then
                            counter = counter + 1
                            End If
                        Next y
                DataWB = ActiveWorkbook.Name 'gets the name of the workbook the program opened
                Workbooks(ThisWB).Activate
                    'have it write the data characteristics to the Summary workbook
                    count = Application.WorksheetFunction.CountA(Range("A:A"))
                    For x = 1 To count
                        If Range("A1").Offset(x, 0) = strNum And Range("A1").Offset(x, 1) = sampleID Then
                            Range("a1").Offset(x, 7) = benchNum
                            Range("a1").Offset(x, 5) = "'" & Left(DataFile, 3)
                            Range("a1").Offset(x, 6) = counter
                        End If
                    Next x
                Workbooks(DataWB).Activate
[COLOR=red]           ActiveWorkbook.Close[/COLOR]
            DataFile = Dir
    Loop 'goes to next data file
Application.ScreenUpdating = True
End Sub
 
I'm not sure if this will address these specific alert boxes, but have you tried this:
Code:
    Application.DisplayAlerts = False 'turns off the alert that would come from the next step

'place code between these lines    

    Application.DisplayAlerts = True 're-enables the alerts
 
You're wanting:

Code:
application.asktoupdatelinks = false

'code here

application.asktoupdatelinks = true
 
the application.displayalerts worked for me, thanks. The other one didn't change anything as far as my code was concerned. Problem solved.

Now if i could only get the submitting department to quit making typos....
 
And I just noticed I completely read your question wrong.
 

Users who are viewing this thread

Back
Top Bottom