Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Saving as a worksheet as a CSV file

MS has posted an article on this behavior.

http://support.microsoft.com/kb/77295

--
Jim
"AJR" wrote in message
...
|I have a macro that formats a worksheet then saves its as a CSV fiel for
| uploading by another system.
| there are 14 fields some of which are blank. The macro works fine but when
| you review the file in notepad, the commas between the blank cells vanish,
| reapesr later and vanish again. If I save manualy then all commas are
present.
| H,Goods In -
Darlington,DTN,DTNFAC,,,,,,,,,,GID,PO,1,2007-01-29,,LBENTLEY,R
| L,42466106,,00009,1,2007-01-29,,,,,,,,,,,,,,
| L,42475301,,00009,1,2007-01-29,,,,,,,,,,,,,,
| L,42490809,,00009,1,2007-01-29
| L,42490907,,00009,1,2007-01-29
|
| Sub Savefile()
|
| For I = 1 To 2
|
| ChDrive "K:\Rhodes\Test Sleeper\Inbox"
| myFileName = Application.GetSaveAsFilename(filefilter:="CSV Files,
*.csv")
| If myFileName = False Then
| Exit Sub 'user hit cancel
| End If
|
| If Dir(myFileName) = "" Then
| 'do nothing, no existing file
| Else
| resp = MsgBox(Prompt:="That file exists, Overwrite?",
| Buttons:=vbYesNo)
| If resp = vbNo Then
| MsgBox "CSV file not saved--Try again later!"
| Exit Sub
| End If
| End If
| 'Search for range of columns and rows
| On Error Resume Next
| RealLastRow = Range("A:T").Find("*", [A1], , , xlByRows,
xlPrevious).Row
| RealLastColumn = Range("A:T").Find("*", [A1], , , xlByColumns,
| xlPrevious).Column
|
| Set myRng = ActiveSheet.Range("A1", Cells(RealLastRow, RealLastColumn))
| 'Selection
|
| 'create a new workbook with a single sheet
| Set wks = Workbooks.Add(1).Worksheets(1)
|
| myRng.Copy
| wks.Range("a1").PasteSpecial Paste:=xlPasteValues
|
| With wks.Parent
| 'Application.DisplayAlerts = False
| Application.DisplayAlerts = True
| .SaveAs Filename:=myFileName, FileFormat:=CSV
| 'Application.DisplayAlerts = True
| .Close savechanges:=False
| End With
| Next I
| End Sub
|
|
|
|
|
|
|
|
|
| --
| Andy


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving only current worksheet into new file BobC Excel Discussion (Misc queries) 3 January 9th 09 01:16 PM
Saving Worksheet to new file by tab name Bobzter100 Excel Discussion (Misc queries) 7 November 12th 07 08:55 AM
Saving worksheet in new file with date AND cell value as file name michaelberrier Excel Discussion (Misc queries) 4 May 26th 06 08:05 PM
Saving to a worksheet in another file...? nickclingan Excel Discussion (Misc queries) 3 February 3rd 06 05:14 PM
Saving worksheet to .doc file CrashandBurn Excel Programming 0 February 10th 04 03:32 AM


All times are GMT +1. The time now is 02:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"