ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   not saving a file (https://www.excelbanter.com/excel-discussion-misc-queries/104797-not-saving-file.html)

stevekirk

not saving a file
 

HI,

I save a file by using a varilbe from a cell then it saves to a CSV
file then it asks if ni want to save changes. and i do not want to save
the file

i have used the FALSE statement but this does not work

thanks
steve
:)


--
stevekirk
------------------------------------------------------------------------
stevekirk's Profile: http://www.excelforum.com/member.php...o&userid=37328
View this thread: http://www.excelforum.com/showthread...hreadid=571304


Dave Peterson

not saving a file
 
Say you have a workbook with 33 worksheets.

You run your code to save the activesheet as a .CSV file (32 other sheets aren't
saved in this .CSV file).

Excel is persistent enough to warn you when you close this file (now a .csv
file) that you may lose lots of stuff (data and formulas and formatting and...).

So it always reminds you when you close that file.

And even if you only had one worksheet to start, you could still be losing
formulas, formatting, ... so it reminds you then, too.

Maybe it would be better to change your code to save the .CSV file differently:

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim newWks As Worksheet
Dim myFileName As String

Set wks = Worksheets("whateveroneyouwanthere")

myFileName = wks.Range("x99").Value

wks.Copy 'to a new workbook
Set newWks = ActiveSheet

With newWks
Application.DisplayAlerts = False
.Parent.SaveAs Filename:="C:\TEMP\" & myFileName, _
FileFormat:=xlCSV
Application.DisplayAlerts = True
.Parent.Close savechanges:=False
End With

End Sub

I saved to the C:\temp folder

stevekirk wrote:

HI,

I save a file by using a varilbe from a cell then it saves to a CSV
file then it asks if ni want to save changes. and i do not want to save
the file

i have used the FALSE statement but this does not work

thanks
steve
:)

--
stevekirk
------------------------------------------------------------------------
stevekirk's Profile: http://www.excelforum.com/member.php...o&userid=37328
View this thread: http://www.excelforum.com/showthread...hreadid=571304


--

Dave Peterson


All times are GMT +1. The time now is 12:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com