VBA to continue automatically when opening files

lyambor

New Member
Joined
Mar 2, 2004
Messages
32
Our code (I copied it and tweaked it from another vba forum) goes out to @ 200 files in a folder and copies a single row into 1 sheet -
works great

But Rather than putting in code to tell it to Don't UpdateLinks or Don't Ask and then getting a second prompt, is there code to tell it to Don't Update after it asks? just assume continue for each file?? so there are no prompts?
I don't want to click on continue for 200 files

the Asktoupdatelinks=false --- still prompts a continue
isent there a updatelinks=0 ?? where would I put it?

_Here is the code so far_______________________________

Sub LoopThroughFolder()

Dim oFSO As Object, sPath As String, wb As Workbook

Set oFSO = CreateObject("Scripting.FileSystemObject")

sPath = Environ("userprofile") & "\Desktop\Testing" 'path


For Each oFile In oFSO.GetFolder(sPath).Files
Set wb = Workbooks.Open(oFile)
Application.AskToUpdateLinks = False
wb.Sheets("Summary").Range("B9:K9").Copy
ThisWorkbook.Sheets("Summary").Range("A" & Rows.Count).End(xlUp)(2).PasteSpecial xlValues
wb.Close False
Next oFile




End Sub

Thank you
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try
Code:
Sub LoopThroughFolder()

Dim oFSO As Object, sPath As String, wb As Workbook

Set oFSO = CreateObject("Scripting.FileSystemObject")

sPath = "C:\mrexcel\" 'Environ("userprofile") & "\Desktop\Testing" 'path


For Each ofile In oFSO.getFolder(sPath).Files
Set wb = Workbooks.Open(ofile, 0)
wb.Sheets("Summary").Range("B9:K9").Copy
ThisWorkbook.Sheets("Summary").Range("A" & Rows.Count).End(xlUp)(2).PasteSpecial xlValues
wb.Close False
Next ofile




End Sub
 
Upvote 0
Try
Code:
Sub LoopThroughFolder()

Dim oFSO As Object, sPath As String, wb As Workbook

Set oFSO = CreateObject("Scripting.FileSystemObject")

sPath = "C:\mrexcel\" 'Environ("userprofile") & "\Desktop\Testing" 'path


For Each ofile In oFSO.getFolder(sPath).Files
Set wb = Workbooks.Open(ofile, 0)
wb.Sheets("Summary").Range("B9:K9").Copy
ThisWorkbook.Sheets("Summary").Range("A" & Rows.Count).End(xlUp)(2).PasteSpecial xlValues
wb.Close False
Next ofile




End Sub

Perfect - thank you so much
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

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