Shows notification and file will closed.

Anonymous
2015-04-18T16:27:12+00:00

I want to show notification when MS Excel 2010 file open that "This file is expired" and after click on Ok Button, file will automatically closed.

It will happen when I set a period approximately one month or a year, the file is opened or used is stop working.

Please help me on this matter.

Thanks

Muneeb

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
OssieMac 48,006 Reputation points
2015-04-26T23:31:09+00:00

Hello again Muneeb,

It works fine for me. I can save as macro enabled workbook without any problems. A copy of the workbook at the following link.

http://1drv.ms/1EGUPMq

I have not protected the VBA project in the uploaded example. I have left that for you to do as per my previous instructions.

Are you trying to save on a server that has protection that will not allow macros? If so, try saving to the hard disk on your computer and see what happens. If it works on your local hard disk then the Server security is possibly the problem so see you system administrator.

If you cannot save to your hard disk on the computer then you need to investigate whether your security software on your computer will not allow files with macros. If this is the case then contact the support people for the security software and see if there is anything you can do about it.

Was this answer helpful?

0 comments No comments
Answer accepted by question author
OssieMac 48,006 Reputation points
2015-04-26T11:32:50+00:00

But the file is not saving as Macro enabled

It shows the following Message

Errors were detecting while saving "Path & Filename". Microsoft Excel may be able to save the file by removing or repairing some features. To make the repairs in a new file, click Continue. To cancel the saving file, click Cancel.

Const ExpirationDate = #5/25/2015#

Const ExpirationDate = #25/5/2015#

Hello Muneeb,

Firstly I am surprised that Excel accepted the date in d/m/y format. My local date format is d/m/y and if I insert the date that way then it automatically changes it to m/d/y format if the day is greater than 12. If the day is not greater than 12 then I finish up with the wrong date. If I enter the date as #25 May 2015# then it also changes the date to #5/25/2015#

I don't suppose you are attempting to insert this macro with the on-line version of Excel. I haven't tried creating a macro with it but to the best of my knowledge, it does not work.

The error message indicates to me that it cannot save the workbook as Macro enabled. This can occur if there is an error in the code that needs fixing before saving. Try inserting the following line at the very top of the page in the VBA editor. (Before the Const declarations.)

Option Explicit

After you have inserted the above line, click on menu item Debug then Compile VBA Project. If Compile VBA Project is disabled (Greyed out) then at some place in the code insert a blank line so the Excel thinks you have made a change. (To do this, position the cursor at the end of a line and press Enter.) and then Select Debug -> Compile VBA Project.

When the code is compiled, if there is a problem in the code that will prevent saving then the debugger will stop on the line and highlight it.

If this does not work then can you upload a copy of the workbook for me.

Guidelines to upload a workbook on OneDrive:

  1. Zip your workbooks. Do not just save to OneDrive because the workbooks open with On-Line Excel and the limited functionality with the On-Line version causes problems.
  2. To Zip a file: In Windows Explorer Right click on the selected file and select Send to -> Compressed (zipped) folder.)
  3. Do not use 3rd party compression applications because I cannot unzip them. I do not clog up my computer with 3rd party apps when there are perfectly good apps supplied with windows.
  4. Go to this link.  https://onedrive.live.com
  5. Use the same login Id and Password that you use for this forum.
  6. Select Upload in the blue bar across the top and browse to the zipped folder to be uploaded.
  7. Select Open (or just double click). (Be patient and give it time to display the file after initially seeing the popup indicating it is done.)
  8. Right click the file on OneDrive and select Share.
  9. Do NOT fill in the form; Select "Get a Link" on the left side.
  10. Click the button "Create a Link"
  11. Click in the box where the link is created and it will highlight.
  12. Copy the link and paste into your reply on this forum.

Was this answer helpful?

0 comments No comments

12 additional answers

Sort by: Most helpful
  1. OssieMac 48,006 Reputation points
    2015-04-23T04:53:56+00:00

    The Message to user must be like this "The file is expired. As we give clear Legal Notice to you."

    The user should then be able to answer "Ok" and then file will closed.

    I need that at least after certain time period excel file can't be edit or change or ammend but can print only.

    Hello Muneeb,

    The above 2 statements from yourself are quite different. My first reply to you suggested an option to either close the workbook or open it in protected mode and allow the User to read the worksheets (and they could also be printed) but you did not want that and wanted to close the workbook.

    As pointed out by John Korchok, "A macro solution can always be bypassed" and similar message in Chip Pearson's solution.

    To make it more difficult to bypass the macros we could protect the worksheets in a Workbook Close event and Save the workbook and then unprotect with the Workbook Open event. If the Workbook open is bypassed due to holding the Shift key while opening then the worksheets will still be protected. However, that has an inherent danger to the user. It is not uncommon for a user to mess up when editing a workbook and decide to close the workbook without saving and re-open and start again and automatic saving the workbook with the Close Event prevents the user from doing that.

    I am inclined to think that the workbook should open at a specific worksheet containing a message to the user advising when the workbook expires. Chip Pearson's solution could be adapted to provide the message the first time the workbook is opened.

    Of course someone else might have a better idea and if so then feel to share it.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2015-04-22T15:47:50+00:00

    Thank you John Korchok & OssieMac for your response but I was delay due to some load of work,

    I have go through the "Time Limiting a Workbook" but it is not suitable for me.

    I need that at least after certain time period excel file can't be edit or change or ammend but can print only.

    Regard

    Muneeb

    Was this answer helpful?

    0 comments No comments
  3. OssieMac 48,006 Reputation points
    2015-04-20T06:46:51+00:00

    To Muneeb,

    Based on your explanation I should think that the link provided by John Korchock to Chip Pearson's site should answer your question but if you need more assistance then feel free to get back to me.

    Was this answer helpful?

    0 comments No comments