Close 'Thisworkbook' then open the another one

CsJHUN

Active Member
Joined
Jan 13, 2015
Messages
360
Office Version
  1. 365
  2. 2021
  3. 2019
Platform
  1. Windows
  2. Mobile
Hi guys,
i'm working on a project which require to save 'thisworkbook' to a specified location and name then open the original workbook.
Main steps which I have in modules and userform:
- workbook open event, register the workbook name (for reopen purposes), open userform
- userform load (its a test/evaluation, the user has to decide if the shown picture is good or not), user fills name and id, then hit the "start" button.
- after the test, the user get the results (good and bad answers with %), the workbook saved in specific location with username, id and timestamp. The result also save in database kind excel.
- the saved workbook name is written in a cell as value (for close purpose)

At this point i need your help.
I want to close this saved workbook (specified name previously), reopen the original workbook with userform loading. Userform is modal (could change to modeless). With this it would be a seamless process between each test, the users dont have to open the original workbook again.

Cheers in advance!
J
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Before 'Save As' store the original name and path in a variable:
VBA Code:
    Dim sFullName As String
    
    sFullName = ThisWorkbook.FullName

then, after the save as you can open it using the variable.

VBA Code:
Workbooks.Open sFullName
 
Upvote 0
Before 'Save As' store the original name and path in a variable:
VBA Code:
    Dim sFullName As String
   
    sFullName = ThisWorkbook.FullName

then, after the save as you can open it using the variable.

VBA Code:
Workbooks.Open sFullName
Yes, im doing that, but how to close the saved test?
opening the original workbook trigger the form open event, which not let close the saved test file.
So IMO i have to pass this saved file name/path/idunno to the original file workbook open event or form initialize.



Is it possible to declare global variable, which should be declared after saving the test, contains the saved file name. And use this variable at the original workbook open event to close the save file before the form loads? (im not even sure i can understand what i wrote :D )
 
Upvote 0
Unless you are changing the file format, you can simply use SaveCopyAs to save a copy (closed) of the current workbook, then reset whatever you need to.
 
Upvote 0
Gallen thanks for your time, RoryA working as charms. From time to time i forget there is more save methods in vba :)
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,936
Members
449,094
Latest member
teemeren

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