T
Trish Smith
Hi all,
I've altered the code for browse and protect that Dave Peterson helped me
with and now it gets stuck in a loop.
The original code looped though all workbooks in browsed for folder and then
looped through all worksheets with a for each loop.
I altered the code to do a different job. What I wanted to do was copy an
array of sheets from the workbook with the code to all the workbooks in the
folder.
Here's the bits of code
This is the end of the browse for filename code
Set myWB = Workbooks.Open(myPath & myName)
Call CopyTemplates(myWB)
Application.AutomationSecurity = AutoSecurity
On Error Resume Next
myName = Dir ' Get next entry.
If myName = "" Then
Exit Do
End If
Loop
End If
End If
Next
End Sub
This is the bit that replaced the for each unprotect
Sub CopyTemplates (myWB As Workbook)
Set myWB = ActiveWorkbook
ThisWorkbook.Worksheets(Array("Datasheet1", "Datasheet2", "Datasheet3", _
"Charts1", "Charts2", "Charts3", "Summary")).Copy _
Before:=myWB.Worksheets(1)
myWB.Close savechanges:=True
End Sub
If anyone could tell me what's missing please, I'd be more than grateful.
Thank you
I've altered the code for browse and protect that Dave Peterson helped me
with and now it gets stuck in a loop.
The original code looped though all workbooks in browsed for folder and then
looped through all worksheets with a for each loop.
I altered the code to do a different job. What I wanted to do was copy an
array of sheets from the workbook with the code to all the workbooks in the
folder.
Here's the bits of code
This is the end of the browse for filename code
Set myWB = Workbooks.Open(myPath & myName)
Call CopyTemplates(myWB)
Application.AutomationSecurity = AutoSecurity
On Error Resume Next
myName = Dir ' Get next entry.
If myName = "" Then
Exit Do
End If
Loop
End If
End If
Next
End Sub
This is the bit that replaced the for each unprotect
Sub CopyTemplates (myWB As Workbook)
Set myWB = ActiveWorkbook
ThisWorkbook.Worksheets(Array("Datasheet1", "Datasheet2", "Datasheet3", _
"Charts1", "Charts2", "Charts3", "Summary")).Copy _
Before:=myWB.Worksheets(1)
myWB.Close savechanges:=True
End Sub
If anyone could tell me what's missing please, I'd be more than grateful.
Thank you