I'm trying to build a Mac that will link to the desktop of the current user, whoever that is.
Using these two macros:
If user 00000000 is logged in, this works. I need something for user 00000000,00000001, 00000002, 00000003, etc.
I tried the following, but none worked:
Using these two macros:
VBA Code:
Sub RunOnAllFilesInFolderWindows()
Dim wbOpen As Workbook
Dim MyDir As String
MyDir = "C:\Users\00000000\Desktop\Action" 'This is the path to your files
'Comment out the 3 lines below to debug'Application.ScreenUpdating = False'Application.Calculation = xlCalculationManual'On Error Resume Next
strExtension = Dir(MyDir & "\*.xlsx")
While strExtension <> vbNullString
Set wbOpen = Workbooks.Open(MyDir & "\" & strExtension)
With wbOpen
Call RemoveUnnecessary
Call RemoveXpoints
Call Rename_Sheet
ActiveWorkbook.SaveAs fileName:="C:\Users\00000000\Desktop\Action\" & ActiveSheet.Name & ".xlsx"
.Close SaveChanges:=True
End With
strExtension = Dir
Wend
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
Sub CombineFilesWindows()
Dim Path As String
Dim fileName As String
Dim Wkb As Workbook
Dim ws As Worksheet
Application.EnableEvents = False
Application.ScreenUpdating = False
Path = "C:\Users\00000000\Desktop\Action\" 'Change as needed
fileName = Dir(Path & "\*.xls", vbNormal)
Do Until fileName = ""
Set Wkb = Workbooks.Open(fileName:=Path & "\" & fileName)
For Each ws In Wkb.Worksheets
ws.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
Next ws
Wkb.Close False
fileName = Dir()
Loop
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
If user 00000000 is logged in, this works. I need something for user 00000000,00000001, 00000002, 00000003, etc.
I tried the following, but none worked:
VBA Code:
C:\Users\*\Desktop\Action
C:\Users\userprofile\Desktop\Action
C:\Users\*%userprofile%\Desktop\Action