![]() |
Need "Filename Equals" code help.
Basically, I am running two message boxes that lead into the save as
menu every time the file S:\Mileage Reimbursement Form.xls is opened. Once the user has saved the file on their own personal network drive space, the message boxes and save as dialog still appear. I do not want this to occur. I keep getting either "End if without Block If" and error 424. How do I code for this? Thanks for any help you can provide. Private Sub Workbook_Open() If Filename.equals("Mileage_Reimbursement_Form.xls") Then MsgBox "Welcome to the mileage form. Please do not modify this form in any way or it may not calculate your mileage correctly. If you need additional rows, please click the 'New Row' button." MsgBox "Before you start filling out this form, please save a copy on your F: drive. You should name the file according to the following format: (Your Name) MM/YYYY Mileage" For Each wb In Workbooks wb.Activate Application.Dialogs(xlDialogSaveAs).Show End If Next End Sub |
Need "Filename Equals" code help.
The cause of the error is that you have End If and Next switched. Reverse
their position. Also, there's a few point in your logic that I do not follow. - I'm not clear what you are doing as , unless this is some class/method that you have written, it's not standard VBA code: If Filename.equals("Mileage_Reimbursement_Form.xls") Then - And if this WB is the "Mileage_Reimbursement_Form.xls" file, then there is no need to check. If this is NOT the "Mileage_Reimbursement_Form.xls" file, then don't put the code in it. - Why do you need to save ALL open workbooks rather than only ThisWorkBook ? Do you need the loop ? - Your can help the user with the save/filename. Look into: Application.GetSaveAsFilename Format(date(),"mm/yyyy") and possibly Environ("Username") NickHK wrote in message ups.com... Basically, I am running two message boxes that lead into the save as menu every time the file S:\Mileage Reimbursement Form.xls is opened. Once the user has saved the file on their own personal network drive space, the message boxes and save as dialog still appear. I do not want this to occur. I keep getting either "End if without Block If" and error 424. How do I code for this? Thanks for any help you can provide. Private Sub Workbook_Open() If Filename.equals("Mileage_Reimbursement_Form.xls") Then MsgBox "Welcome to the mileage form. Please do not modify this form in any way or it may not calculate your mileage correctly. If you need additional rows, please click the 'New Row' button." MsgBox "Before you start filling out this form, please save a copy on your F: drive. You should name the file according to the following format: (Your Name) MM/YYYY Mileage" For Each wb In Workbooks wb.Activate Application.Dialogs(xlDialogSaveAs).Show End If Next End Sub |
All times are GMT +1. The time now is 02:34 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com