excel vba saveas overwrite error Cumnock North Carolina

Address Apex, NC 27502
Phone (888) 787-2256
Website Link http://bitbacked.com

excel vba saveas overwrite error Cumnock, North Carolina

Got a question on Linux? Please post a thread in the appropriate forum. Option Explicit Sub test() Dim sInitF As String Dim sFilter As String Dim sFileName As String sInitF = "zzzz.xlsm" sFilter = "Excel Files(*.xlsm),*.xlsm" If GetSaveAs(sInitF, sFilter, sFileName, ActiveWorkbook.FullName) Then On Error Peter Thornton Tuesday, February 26, 2013 9:10 PM Reply | Quote Moderator 0 Sign in to vote In forums like this when you see something prefixed with "my..." it's meant as

Ideally by design and the use of date code I should not really run into the same file name twice. Even though the macro has been recorded by approving the replacement (the prompt appears "the file --- already exists. Using it with caution (which means properly) does not make it 'not proper programming'. The trick is to control it.

VB Code: 'at top of codeDim objExcel As New Excel.ApplicationDim objBook As New Excel.Workbook'then the savedata subWith objExcel Set objBook = .Workbooks.Add'write some stuffEnd With'save the fileobjBook.SaveAs FileName'destroy objectsobjExcel.Workbooks.Close fName$ = Application.GetSaveAsFilename ActiveWorkbook.SaveAs Filename:=fName$ _ This works fine except when I try to give the saved file a name that already exists. already", , "ERROR IN CODE THAT CALLED PadLeft" Exit Function '<===== Exit Function End If 'If "" was passed, then assume they meant " " If Len(sChar) = 0 About Us PC Review is a computing review website with helpful tech support forums staffed by PC experts.

thanks Tuesday, February 26, 2013 6:55 PM Reply | Quote 0 Sign in to vote The problem appears to be in my formula that creates the file name. Check out all the free tutorials and VBA code snippets! Now you can read and write from/to C43. error trapping:- you have the gist of it and a review of the 'on error' documentation in help will help you understand it better.

Reply With Quote May 4th, 2005,08:31 AM #5 Hack View Profile View Forum Posts Super Moderator Join Date Aug 2001 Location Searching for mendhak Posts 58,335 Re: VB-Excel SaveAs method, if If you need to manage the process in more detail, you could use something like thisConst strFilename As String = "D:\weg\Map1.xls" Dim strMsgText As String Dim msgboxresponse As Integer strMsgText = Method SaveAs of object _Workbook failed. MAKE SURE that you include this function along with any of the application macro code versions shown below.

for example: On Error Resume Next MkDir sNewPath In this case you are skipping any error which occurs as a result of trying to make a directory Want to Advertise Here? When you have received an answer to your question, please mark it as resolved using the Thread Tools menu. If its not saved then its new and doesnt exist.

However I received a question from a reader who goes by the name Kauket, asking if it was possible to automate saving a new version for a file. Why are unsigned numbers implemented? All rights reserved. Browse other questions tagged vba excel-vba or ask your own question.

sArr = Split(sWork, sSep) sFnIncrMaybe = sArr(UBound(sArr)) If Len(sFnIncrMaybe) <> lenIncr Then bVirgin = True Else 'The sSep was in the correct place, but Results 1 to 18 of 18 Thread: VB-Excel SaveAs method, if file exists, rename without prompting Tweet Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Before posting your question, did you look here? Solve and naming variables What kind of bicycle clamps are these?

For this reason, "On Error" is often the only way to handle a situation and can sometimes be more efficient than the alternatives. However, I would still treat it's use with caution (particulary in conjuction with GoTo) since it's a sad reality that many people don't realise the pitfalls of it's improper use. Are you sure you > want that? > > And I wasn't sure if you wanted to close the activeworkbook if the save > was canceled. > > > > On Once the file is closed and the object is destroyed, the active workbook then became "Book1".

Everything else is the same! Solved How can I prevent overwriting an existing file when saving a file using Excel VBA? If it was possible: when prompted to overwrite existing file by pressing button “No” code reopens the file “SaveAs” dialog window. If you need a walk-through on how to insert a macro into Microsoft Word to use across any of your Word Documents, you can check out an earlier post I wrote

Share it with others Twitter Linked In Google Reddit StumbleUpon Posting Permissions You may not post new threads You may not post replies You may not post attachments You may not And if you show the SaveAs dialog, the user can still overwrite that file, right? Once an error condition is generated the enabled sequence becomes 'active', if a further error occurs the 'active' error handler will fail: - each function (or sub) can have one enabled Read this: Cross-posters Struggling to use tags (including Code tags)? : Forum tags July 26th, 2003 #3 Ivan F Moala View Profile View Forum Posts Visit Homepage Established Member Join Date

Why do I get this error? No, create an account now. Try Free For 30 Days Suggested Solutions Title # Comments Views Activity What is wrong with this VLOOKUP formula in Excel 2007? 13 33 14d Draw several entries from another worksheet On error got 0 disables the current 'enabled' error handler - and the nesting still applies.

Can we change the the parameters in function "ActiveWorkbook.SaveAs Filename"? Do you want to replace the existing file?"), when I run the macro, I am again prompted about replacing the file. Also check for unintended code wrapping as posted. You can just paste the below code below either the Excel, PowerPoint, or Word subroutines.Function FileExist(FilePath As String) As Boolean'PURPOSE: Test to see if a file exists or not'SOURCE: www.TheSpreadsheetGuru.com/The-Code-Vault'RESOURCE: http://www.rondebruin.nl/win/s9/win003.htmDim

Share Share this post on Digg Del.icio.us Technorati Twitter Richard Schollar Using xl2013 Reply With Quote Sep 1st, 2008,01:29 AM #8 soodaarti21 New Member Join Date Jun 2008 Posts 48 Re: When you have received an answer to your question, please mark it as resolved using the Thread Tools menu. Any help would be gratefully accepted! Member Login Remember Me Forgot your password?

The cell contains a formula "=CONCATENATE("PM Checklist_",$D$26,"_",$D$28,"_",TEXT(D20,"mmm/dd/yyyy"),"_",$D$24)" that generates the filename.