BeforeSave Cause Crashes

Dec 3, 2009

I have the following code that (should) either save the file with a generic name if a value exists in a certain field, or else save the file as the contents of the value in the field, with a message box appearing in either case. The problem is, the message box appears twice (not once) and then Excel crashes! Can anyone tell me what's going on? The code is:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim FSR As String
FSR = Range("I7").Value
If FSR = "" Then
MsgBox "Service Report Number not entered."
ActiveWorkbook.SaveAs Filename:="Service Report Navilas.xls"
End If

If FSR "" Then
MsgBox "This action will save the file as the Service Report Number."
ActiveWorkbook.SaveAs Filename:=FSR & ".xls"
End If

End Sub

View 6 Replies


ADVERTISEMENT

BeforeSave Workbook Event

Apr 20, 2007

I am trying to find out more info regarding the BeforeSave workbook event, need example of a short procedure that would prevent the user from saving the workbook with the current workbook name, and would automatically force the file to save as a web page? I'm sorry that I don't have any examples of code that I'm working with, and it feels pretty juvenile to just ask someone to write code for me. But I haven't been able to get past step one with this.

View 2 Replies View Related

BeforeSave And BeforePrint Code Does Not Work

Jun 13, 2008

the following code work on both PC and mac? It works fine on PC, but on mac the BeforeSave and BeforePrint code does not work and the SaveASheet code gets as far as opening and pasting the sheet but then is unable to save automatically.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
SaveASheet
End Sub
Private Sub Workbook_Open()
Sheets("Open").Activate
End Sub
Sub SaveASheet()
Dim fName As String
Dim myPath As String
Dim sht As Worksheet
#If Mac Then..........

View 9 Replies View Related

Workbook>Beforesave Function To Add Cell Borders

Feb 9, 2010

I have a spreadsheet that I'm working on and I'd like to include a beforesave macro to format the spreadsheet. Basically I need a macro to select all rows with data in column 'a' and add a thick border to the top of the cells. Ideally the border would stop at column 'i' but that's not essential. I've attached an example of what I'd like. I've included 2 sheets 1 called 'before' and 1 called 'after'. They show what I'm after.

View 3 Replies View Related

BeforeSave, Create Folder & Sub-foldername If Has Not Been Created

Oct 13, 2004

Example below is in my macro and when my peer is running this worksheet which has Workbook_Open() enabled in "ThisWorkbook", the outcome is that he can not successfully save this workbook because he doesn't have the folder and sub directory in his C: drive.

How do I code it such that in the event the user does not have the specified folder and sub-foldername, it will automatically create one for him and save it as "C:Spare PartsCritical ListStocking Status.xls".

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:= _
"C:Spare PartsCritical ListStocking Status.xls"

View 3 Replies View Related

Code In BeforeSave Event Causing A Double Save

Jul 22, 2009

In the situation where I shut down my model (i.e. not just press Ctrl+S, but shut it down), the following code saves the model twice. I only want it to save once. I really can't see why it saves a second time.

NB: I know if you set Cancel to True in the BeforeSave event, it should prevent the model from saving after the event, but even when set to true in the below code, it still saves...

Private Sub Workbook_BeforeClose(Cancel As Boolean)
bIsClosing = True 'Given we shut model, this public bIsClosing is set to true...
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim wsArray() As Variant
Dim iCnt As Integer
Dim wsSht As Worksheet
Application. ScreenUpdating = 0
Splash.Visible = True 'Splash is codename for warning spreadsheet, this is left
'visible while all other sheets are to be hidden.......................

View 9 Replies View Related

Crashes On 2nd Run

Apr 14, 2009

I have the following code which filters data in a sheet, and loads the numbers into textboxes on a userform. There are two multipage controls, each with several textboxes on them. I have commented out several lines because if I leave any of them in, it crashes excel.

It will work once. But if I close the workbook, re-open it, and run the code again, it crashes.

The thing I find really interesting is that all the 'problem lines' were added in as part of a retro-fit. The person I created this workbook for needed one more column of data. I followed the same programming pattern as what I used on the other, but only these ones seem to cause problems. Any thoughts?

NOTE: The message boxes were just to help me figure out which lines of code were causing the crash. ....

View 9 Replies View Related

Do Until And Crashes

Mar 5, 2007

My main workbook basically starts with, Sub macro1 (), Do Until, Web Query, many many many calculations in between and finally ActiveWorbook.Save.

After ActiveWorbook.Save it will start the same process with a new web query and works all perfectly and perpetually just as I would like it to....

View 9 Replies View Related

Listbox Crashes

May 14, 2007

I'm trying to use a listbox and wanted to have the data sit in a different sheet. When I do this, I get a message about low memory and then excel says it has an error and shuts down. When I move the data to the same sheet as the listbox, there is no problem.

I'm using excel 2000 and that's all I can get (at work). Any thoughts? Should I just put the data on the same sheet and hide it? Is there a way around this?

View 9 Replies View Related

Crashes Constantly

Oct 19, 2007

Just recently Excel crashes about 4 out of 5 times. Any advice to where I should start looking and how to handle this please?

View 7 Replies View Related

UserForm Crashes

Jan 4, 2008

It is a simple form which has a Module/Macro to load the form on clicking a shape.
Although the form works fine for me it occasionally crashes for other user.
The Debug says that there is an error in the Module with the line "frmCallData.Show".
Below is the Code for the form and also the Module: ....

View 6 Replies View Related

Crashes Without Warning

Jun 6, 2008

On one laptop Excel crashes, without warning. It happens during copy/paste job (from one workbook to another). But not every time she copies something.

It is completly the same laptop like others in my company. My user has deadlines, and lot of copy/paste job.

View 8 Replies View Related

Open And It Crashes Down?

Jan 25, 2009

Whenver I open the Excel App it crashes down ? Why ?

I Deactivated all the add ins, but the problem still exists.

Deleted the registery of Excel and un- install the Excel App then Re-install it again, but the problem still exists......

View 8 Replies View Related

Crashes Logs

Feb 12, 2009

I wrote some VBA code detailed here. Is there any Excel Crash log I can look at? I have tested it on three computers. It worked on my computer just fine, but when testing it on the two other users of this spreadsheet it crashes when they click the mouse on a list box after about 5 to 10 clicks.

View 9 Replies View Related

Crashes When Saving Workbook...

Jun 8, 2009

As I've learned to develop Excel apps with vba over the years I've noticed that, if the Excel app starts to get too large (over 1MB) saving it will often cause the application to crash for no apparent reason - the result being that I lose all the vba code I entered before the last save - with the worst case being that, on occasion I have lost all of the vba code in an applications!!!

So, I've learned to back up often using a third-party utility that I use to save my applications, which works wonders in allowing me to save my application without it crashing. The application is called Code Cleaner 97.exe. It was designed around Excel 97 (which I still use) but if possible I'd like to get an updated version for Excel 2003 and Excel 2007, which I also use.

Does anyone know of a more recent version of this utility, or another similar utility that allows large Excel applications to be properly saved, etc?

Code Cleaner 97.exe was a freebie that was available through one of the old Compuserve Excel forums. It was a very popular utility and was suggested as a means to save one's Excel apps without the app getting trashed, etc.

I'm not expecting a freebie solution so I'll gladly pay for something that allows me to save my large Excel apps without them crashing, etc.

View 2 Replies View Related

How Many Records To Sort Without Crashes

Oct 3, 2009

I have a column of data that is an 850,000+ list of phone numbers. I need to peridoically insert another 10,000+ at a time and see if there are duplicates. Using conditional formatting to highlight the duplicates with a colored cell, and then sorting those records to the top is what I want to do, but it's too much for Excel to handle, and it hangs. It looks like I need to break up the 850k records into smaller chunks. Anyone know what an average pc with Excel 07 can handle? It's a 2.8ghz w/2gb ram.

View 6 Replies View Related

Solver Macro Crashes

Jan 25, 2010

When I run a group of macros for some reason after the marcro runs and I hit F2 excel crashes.

I have figured out that it is one of the marcros that makes the excel crash. It is only when I run the solver application. The code is below. Any thoughts why hitting F2 after running this marcro would crash the machine?

View 10 Replies View Related

Crashes With Application.quit

Apr 2, 2007

I'm trying to close out excel through a user form (excel is hidden) button but excel crashes when it reaches the application.quit line of code.

I searched google and found one message that said that if you have add-ins that they can cause excel to crash when closing but there was no explanation or work around.

Is there a way around this problem?

View 7 Replies View Related

SaveAs Error Crashes

Dec 15, 2007

I have a very strange error at present. I am saving a sheet as a file using VBA from within Excel and when I run the program from the environment of my flash drive it works without a problem but when I run the same code on my main PC it causes an error :

Run time error 1004
Method SaveAs error ... and it causes Excel to crash and then recover the file.

The code that causes this is shown below : ....

View 6 Replies View Related

Macro Runs For A Bit And Then Crashes

Feb 15, 2008

I have created a macro in xl2000 which was working fine - although through corporate upgrades my machine has now been upgraded with xl2003 and the macro runs for a bit and then crashes on the code below, although it only highlights teh 'rnum'

rnum = ActiveCell.Row
Is there a difference between xl2000 & xl2003?

View 9 Replies View Related

Crashes When Inserting A Comment

Jun 17, 2008

I open Excel. I click Insert-> Comment. Excel crashes. I try to open an excel file with comments, Excel crashes. I have already uninstalled and reinstalled, Detected & Repaired. Nothing appears in the event viewer. I am at my wits end.

Any ideas on what this could be? My only guess is a windows issue vs. an excel issue, but I thought I'd at least ask.

View 6 Replies View Related

Vba Form Crashes Intermittent

Feb 6, 2009

I have written a fairly large spread sheet, and I have consistently had excel crashes when the first form initialises at startup.
However if I resave the workbook over itself or sometimes as another name it will then work. Once it works - it will always work while I dont restart my computer. The next day the same workbook will crash on form startup. Once this happens t always crashes on startup. If it works OK first up it always works. However if I edit it the process may happen all over again. I am 100% their is no error in the code as in certain stages it has worked for months. It seams like some bug in excel?
Has anyone ever had this issue?

View 9 Replies View Related

File Crashes When Opened

Jul 14, 2006

I run a macro which runs saves the active file to a different location to ensure that I retain the original like so -

If ActiveWorkbook. Name = "KEY_DATA_CFT77" + ".xls" Then
ActiveWorkbook.SaveAs Filename:= _
"H:HOME imcEXCELKEY_DATA_2006KEY_DATA_2006_01KEY_DATA_CFT77_01.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False
End If .................................

View 9 Replies View Related

Add Beforeprint To New Workbook Crashes?

Apr 3, 2007

I’m launching a new workbook, exporting some stuff, basically creating a report. But then I want to add a BeforePrint event to the new worksheet. Both of the macro below works great right up until I change “Sheet1” to “ThisWorkBook”…then Excel crashes.

Sub AddCode1()
Dim VBCodeMod As CodeModule
Dim LineNum As Long
Dim Copybook As Workbook
Set Copybook = Excel.Workbooks.Add
Set VBCodeMod = Copybook.VBProject.VBComponents("sheet1").CodeModule
LineNum = VBCodeMod.CountOfLines + 1
VBCodeMod.InsertLines LineNum, "Private Sub Workbook_BeforePrint(Cancel As Boolean)" & Chr(13) & "if ActiveSheet.CodeName <> ""Sheet1"" or ActiveSheet.CodeName <> ""Sheet2"" or ActiveSheet.CodeName <> ""Sheet3"" then" & Chr(13) & "MsgBox(""This Electronic Outcome Review Summary Report is NOT optimized for Printing......................................

View 5 Replies View Related

Userform Crashes Upon Submitting

May 4, 2007

I worked really hard on this userform for a work project - my first and likely last attempt at coding!

It used to work, and then I changed a bunch of listboxes to comboboxes, and now my file gives the 'Excel has encountered a problem and needs to close' error - but ONLY when I'm working directly with the excel file and NOT when I've got VBA open.

Compiling shows no problems - I have no idea what to do because this is a very important file for work and I am a very inexperienced coder! ...

View 7 Replies View Related

Debug.Print Cause Crashes

May 18, 2007

Continuing with my goal to learn VBA and while playing with the following code, I encountered strange behavior of debug statements. In the code below I have put my comments to identify where the "funny behavior" is encountered.

Will appreciate if you can help me understand. I also have a simple request/question at the end of the code below: ....

View 7 Replies View Related

Vlookup Crashes Userforms

May 22, 2007

I'm having a problem with Vlookup locking up excel everytime it tries to call a userform. If I rem either the .show lines or the entire Vlookup loop it works. I suspected it was the exit handler but that doesn't seem to be the case. If I use vlookup code and data validation instead of vb vlookup it all works except for the problem of having the code in the cells overwritten. It's probably something really simple that I overlooked. Any suggestions would be welcome. Newvendin is a multi-input textbox and frmcalendar is a calendar....

View 6 Replies View Related

Workbook Crashes On Open

Jun 14, 2008

Three times (by three different users) over the past two months, a workbook has gotten into what appears to be some sort of corrupted state. When you attempt to open the workbook you get the "report to Microsoft" screen which states "Microsoft Excel has encountered a problem and needs to close". Proceeding on this screen closes the entire instance of Excel, including the offending workbook and any others that are open. However, if I simply open and save the workbook in Excel safe mode, then it resolves the problem. But, again, it has happened three times so it keeps coming back.

A little more background: there is a custom add-in referenced which contains many custom functions. This add-in is also referenced by other workbooks, none of which have had this problem. The Workbook_Open event only does what I consider to be superficial processing; it hides some sheets, selects a sheet, defaults some shape colors, and defaults a checkbox to True. In other words, nothing too heavy going on at startup, in my opinion. I have tried several times to break into the code between the time the workbook begins to load and when the "report to Microsoft" screen is displayed, but this was unsuccessful.

I was hoping that the fact that simply saving it from safe mode resolves the problem might indicate the problem to someone on the forum. I have a copy of the file in its corrupted state but I have not attached it because it contains some business sensitive information.

View 7 Replies View Related

External Links Cause Program Crashes

Jan 4, 2009

My system is Vista Ultimate with Office 2007. I use Norton Internet Security 2007 with Microsoft Office Automatic Scan disabled.

For many years I have used a spreadsheet which links to an external data source - eSignal. eSignal provides real time updates to the spreadsheet.

The problem occurs after I click the link to enable automatic update of links.

About 2 out of 3 times when I load this spreadsheet Excel has a problem with indigestion and closes.

Here is the problem report:

Problem signature
Problem Event Name:APPCRASH
Application Name:EXCEL.EXE
Application Version:12.0.6331.5000
Application Timestamp:48fa2869
Fault Module Name:EXCEL.EXE
Fault Module Version:12.0.6331.5000
Fault Module Timestamp:48fa2869
Exception Code:c0000005
Exception Offset:000453a2
OS Version:6.0.6001.2.1.0.256.1
Locale ID:1033

Extra information about the problem
LCID:1033
Brand:Office12Crash
skulcid:1033
Bucket ID:1048410467

Does anyone have any idea how this error can be avoided? (Even with a clumsy workaround?)

View 12 Replies View Related

Using Sort Function In Macro Crashes

Jun 3, 2009

I have a report I produce where I take an XML file, sort it and run some simple formulas then sort another way and run a few more formulas then update a pivot table. The XML files I'm using have the same headers but vary in length. When I set the macro up for a particular XML file everything works fine. When I import another one (different size) I get the error message:

Run-time error ‘1004’:
Sort method of Range class failed

When I look at the code I see that the range is fixed to the XML file I used when setting the macro up. Is there a way to auto-select the table in the macro so I can run the same macro on any size XML?

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved