Run Macro from other workbook

Theyman

New Member
Joined
Nov 16, 2012
Messages
1
Please assist, I don`t know what i did wrong here.

Sub AllWorkbooksMacro()
GoodStart
'CopyFilesArcs
'Sub AllWorkbooksMacro()
Dim myPath As String
Dim myFile As String
Dim wbk As Workbook
Dim oFSO As Object
Dim oFile As Object
Dim oFiles As Object
Dim oFolder As Object

myPath = "C:\Users\Theyman\Documents\Advance On Point Solutions\Progress Reports\2022\7.July\Arcs"
If Right(myPath, 1) <> "\" Then myPath = myPath & "\"
myFile = Dir(myPath & "*Advance*.xlsm", vbNormal)

If Len(myFile) = 0 Then
MsgBox "Nothing found...", vbExclamation
Exit Sub
End If

Do While Len(myFile) > 0
Set wbk = Workbooks.Open(FileName:=myPath & myFile)
Set Awbk = ActiveWorkbook

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(myPath) 'You must initialize this before
Set oFiles = oFolder.Files


'For all files in the folder
For Each oFile In oFiles
If (oFile Like "*.xls*") Then
Set Awbk = Workbooks.Open(FileName:=oFile)
DoEvents
'Call ReCaptureEntireMonth(Awbk)
Application.Run "'" & myPath & myFile & "'!ReCaptureEntireMonthLIsle"
Awbk.Close SaveChanges:=True
DoEvents
End If
Next
Loop
End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Posting code without an explanation is not a good idea. Unless you explain the details of exactly what went wrong, it is difficult for anyone else to help.

(Tip: For future posts , you should try to use code tags. It makes it easier to read.)

 
Upvote 0
Solution

Forum statistics

Threads
1,214,592
Messages
6,120,433
Members
448,961
Latest member
nzskater

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