Can you stop a workbook from opening when macros are disabled and give a messagebox to the user saying, "To enter the workbook please enable your macros."
And can you name a workbook after the contents of cell "A1"?
Can you stop a workbook from opening when macros are disabled and give a messagebox to the user saying, "To enter the workbook please enable your macros."
And can you name a workbook after the contents of cell "A1"?
Hi Kane, welcome to VBAX!
Addressing your questions seperately as 1 and 2 ...
Question 1:
You can't really. Not with code. What you can do is do some (of what I call) 'backwards programming'. Examples can be found ..
http://j-walk.com/ss/excel/tips/tip100.htm
http://www.mrexcel.com/board2/viewtopic.php?t=121978
http://www.mrexcel.com/board2/viewtopic.php?t=101300
Question 2:
You can use something like this ..
Note: If you DON'T want to delete the original copy of the file (prior to saveAs) then delete the Kill .. line (last line of code).Sub RenameWorkbookAfter_A1() Dim fPath As String fPath = ThisWorkbook.FullName ThisWorkbook.SaveAs ThisWorkbook.Path & "\" & Sheets("Sheet1").Range("A1").Value Kill fPath End Sub
HTH
Regards, Zack Barresse
Check out the KB! :|: BOARD TAGS: WHAT ARE THEY AND HOW DO I USE THEM
What is a Microsoft MVP? | Free Microsoft Courses | My Book on Excel Tables
A simple method to try, but not a high level of security; hide or password protect the sheets with a BeforeClose macro which requires an OnOpen macro to restore the sheets for use. If you need code for this, let us know.
To name the book, try
MyDir = "C:\ATest\" MyFile = Sheets("Sheet1").Range("A1").Text ActiveWorkbook.SaveAs Filename:=MyDir & MyFile
Which, btw, these methods could fail if the file already exists and you choose to cancel out of the save. You can code around that though, depending on if you want to overwrite or not..
Regards, Zack Barresse
Check out the KB! :|: BOARD TAGS: WHAT ARE THEY AND HOW DO I USE THEM
What is a Microsoft MVP? | Free Microsoft Courses | My Book on Excel Tables
Wow, thanks. Both problems solved. This is a great service. Keep up the good work.
Great, glad it works for you! I'll go ahead and mark this solved. You can do so on your posts by going to Thread Tools --> Mark Thread Solved --> Perform Action.
Take care!
Regards, Zack Barresse
Check out the KB! :|: BOARD TAGS: WHAT ARE THEY AND HOW DO I USE THEM
What is a Microsoft MVP? | Free Microsoft Courses | My Book on Excel Tables