Pause VBA script for user input/confirmation ?

netrixuser

Board Regular
Joined
Jan 21, 2019
Messages
77
Office Version
  1. 365
Platform
  1. 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.

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]
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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