netrixuser
Board Regular
- Joined
- Jan 21, 2019
- Messages
- 77
- Office Version
- 365
- Platform
- Windows
Hiya, I'm a newly registered user with newly registered user problems !! VBA is steep learning curve for me, but hopefully with your help I will get there.
I have a basic script that opens up three Excel spreadsheets, puts them in three separate tabs. My current issue is that the spreadsheets it is opening are in my download folder on my Win10 machine meaning that if someone else was to run the script it would fail because the path to the files would be wrong - sould could the script be paused for the user's ID to be entered ?, also, I would like a check to confirm the spreadsheets (3 different reports) have the correct filename, and if not the user could somehow enter the filename and it be replaced in the script ?
My script is below (and the user ID and filename was highlighted by me, not VBA) - thanks in advance for any assistance.
Netrixuser.
I have a basic script that opens up three Excel spreadsheets, puts them in three separate tabs. My current issue is that the spreadsheets it is opening are in my download folder on my Win10 machine meaning that if someone else was to run the script it would fail because the path to the files would be wrong - sould could the script be paused for the user's ID to be entered ?, also, I would like a check to confirm the spreadsheets (3 different reports) have the correct filename, and if not the user could somehow enter the filename and it be replaced in the script ?
My script is below (and the user ID and filename was highlighted by me, not VBA) - thanks in advance for any assistance.
Netrixuser.
Code:
[INDENT] Sub Get_Reports()[/INDENT]
[INDENT]
[/INDENT]
[INDENT]'The script will open the three reports[/INDENT]
[INDENT]
[/INDENT]
[INDENT] Sheets("Sheet1").Select[/INDENT]
[INDENT] ControlFile = ActiveWorkbook.Name[/INDENT]
[INDENT] Workbooks.Open Filename:="C:\Users\[B][COLOR=#ff0000]bartg0[/COLOR][/B]\Downloads\[COLOR=#ff0000][B]Active MR[/B][/COLOR][COLOR=#ff0000][B]L[/B][/COLOR]"[/INDENT]
[INDENT] ActiveSheet.Name = "Accsys Report"[/INDENT]
[INDENT] Sheets("Accsys Report").Copy After:=Workbooks(ControlFile).Sheets(1)[/INDENT]
[INDENT] Windows("Active MRL").Activate[/INDENT]
[INDENT] ActiveWorkbook.Close SaveChanges:=False[/INDENT]
[INDENT] Windows(ControlFile).Activate[/INDENT]
[INDENT]
[/INDENT]
[INDENT]
[/INDENT]
[INDENT] Sheets("Sheet1").Select[/INDENT]
[INDENT] ControlFile = ActiveWorkbook.Name[/INDENT]
[INDENT] Workbooks.Open Filename:="C:\Users\bartg0\Downloads\report_011419_141603"[/INDENT]
[INDENT] ActiveSheet.Name = "Fonetic Report"[/INDENT]
[INDENT] Sheets("Fonetic Report").Copy After:=Workbooks(ControlFile).Sheets(1)[/INDENT]
[INDENT] Windows("report_011419_141603").Activate[/INDENT]
[INDENT] ActiveWorkbook.Close SaveChanges:=False[/INDENT]
[INDENT] Windows(ControlFile).Activate[/INDENT]
[INDENT] Sheets("Sheet1").Select[/INDENT]
[INDENT] ControlFile = ActiveWorkbook.Name[/INDENT]
[INDENT] Workbooks.Open Filename:="C:\Users\bartg0\Downloads\All_Devices_Status_BP"[/INDENT]
[INDENT] ActiveSheet.Name = "Cognia Report"[/INDENT]
[INDENT] Sheets("Cognia Report").Copy After:=Workbooks(ControlFile).Sheets(1)[/INDENT]
[INDENT] Windows("All_Devices_Status_BP").Activate[/INDENT]
[INDENT] ActiveWorkbook.Close SaveChanges:=False[/INDENT]
[INDENT] Windows(ControlFile).Activate[/INDENT]
[INDENT]End Sub[/INDENT]