Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Trouble with SaveAs .csv

Hello,

I am very new to programming with VBA in Excel, but am trying to learn
as much as possible, and these groups are certainly an excellent
resource for that. So here is my problem.

Each day I need to:
1) Open up an Excel file linked to several other files
2) Break the links to the other files
3) Delete a column
4) Save the file as an .xls file with the current date
5) Save a second copy as a .csv file (with same file name each day)
6) Upload .csv file to our database

I've been trying to break this down into steps and write code for each
step as I learn it. So far I've done steps 2-5 with the code below.

Sub SavePriceUpload()

'

' Comment: Save as Date

' Created on 7/27/2006

'

Sheets("Sheet1").Activate

Cells.Select

Selection.Copy

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _

:=False, Transpose:=False



Columns("H:H").Select

Range(Selection, Selection.End(xlToRight)).Select

Selection.Delete Shift:=xlToLeft



dtmDate = Date



strMonth = Month(Date)

strDay = Day(Date)

strYear = Right(Year(Date), 2)



ActiveWorkbook.SaveAs Filename:= _

"F:\PRICEUPLD\Price\PriceUpload" & strMonth & "-" & strDay & "-" &
strYear & ".xls"



ActiveWorkbook.SaveAs Filename:= _

"F:\PRICEUPLD\price.csv"



End Sub

Everything seems to work great, except when I try to upload the .csv
file to my database it fails. If I open the .csv file in a text editor
I can see that there is a bunch of other info that doesn't show up when
I open the csv file in Excel, like my VBA code. So any ideas how I can
do this without the extraneous data. Let me know if I'm going about
this in entirely the wrong way.

Thanks,
Dylan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Trouble with SaveAs .csv

I can't imagine what the extraneous data might be.

But to have more control you might look at Chip Pearson's code.

http://www.cpearson.com/excel/imptext.htm import/export text files

--
Regards,
Tom Ogilvy


" wrote:

Hello,

I am very new to programming with VBA in Excel, but am trying to learn
as much as possible, and these groups are certainly an excellent
resource for that. So here is my problem.

Each day I need to:
1) Open up an Excel file linked to several other files
2) Break the links to the other files
3) Delete a column
4) Save the file as an .xls file with the current date
5) Save a second copy as a .csv file (with same file name each day)
6) Upload .csv file to our database

I've been trying to break this down into steps and write code for each
step as I learn it. So far I've done steps 2-5 with the code below.

Sub SavePriceUpload()

'

' Comment: Save as Date

' Created on 7/27/2006

'

Sheets("Sheet1").Activate

Cells.Select

Selection.Copy

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _

:=False, Transpose:=False



Columns("H:H").Select

Range(Selection, Selection.End(xlToRight)).Select

Selection.Delete Shift:=xlToLeft



dtmDate = Date



strMonth = Month(Date)

strDay = Day(Date)

strYear = Right(Year(Date), 2)



ActiveWorkbook.SaveAs Filename:= _

"F:\PRICEUPLD\Price\PriceUpload" & strMonth & "-" & strDay & "-" &
strYear & ".xls"



ActiveWorkbook.SaveAs Filename:= _

"F:\PRICEUPLD\price.csv"



End Sub

Everything seems to work great, except when I try to upload the .csv
file to my database it fails. If I open the .csv file in a text editor
I can see that there is a bunch of other info that doesn't show up when
I open the csv file in Excel, like my VBA code. So any ideas how I can
do this without the extraneous data. Let me know if I'm going about
this in entirely the wrong way.

Thanks,
Dylan


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Trouble with SaveAs .csv

Thanks Tom,

The extra data appears to be formatting data along with the VBA code.
It seems that the file is not truly getting saved as a .csv file, since
when I look at it in notepad there are no commas.

Thanks for the link to Chris Pearson's code. I need to go through it
in more detail, but it looks like I'll be able to modify it for my
needs.

Dylan

I appreciate the link to Chris Pearson's code.

Tom Ogilvy wrote:
I can't imagine what the extraneous data might be.

But to have more control you might look at Chip Pearson's code.

http://www.cpearson.com/excel/imptext.htm import/export text files

--
Regards,
Tom Ogilvy


" wrote:

Hello,

I am very new to programming with VBA in Excel, but am trying to learn
as much as possible, and these groups are certainly an excellent
resource for that. So here is my problem.

Each day I need to:
1) Open up an Excel file linked to several other files
2) Break the links to the other files
3) Delete a column
4) Save the file as an .xls file with the current date
5) Save a second copy as a .csv file (with same file name each day)
6) Upload .csv file to our database

I've been trying to break this down into steps and write code for each
step as I learn it. So far I've done steps 2-5 with the code below.

Sub SavePriceUpload()

'

' Comment: Save as Date

' Created on 7/27/2006

'

Sheets("Sheet1").Activate

Cells.Select

Selection.Copy

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _

:=False, Transpose:=False



Columns("H:H").Select

Range(Selection, Selection.End(xlToRight)).Select

Selection.Delete Shift:=xlToLeft



dtmDate = Date



strMonth = Month(Date)

strDay = Day(Date)

strYear = Right(Year(Date), 2)



ActiveWorkbook.SaveAs Filename:= _

"F:\PRICEUPLD\Price\PriceUpload" & strMonth & "-" & strDay & "-" &
strYear & ".xls"



ActiveWorkbook.SaveAs Filename:= _

"F:\PRICEUPLD\price.csv"



End Sub

Everything seems to work great, except when I try to upload the .csv
file to my database it fails. If I open the .csv file in a text editor
I can see that there is a bunch of other info that doesn't show up when
I open the csv file in Excel, like my VBA code. So any ideas how I can
do this without the extraneous data. Let me know if I'm going about
this in entirely the wrong way.

Thanks,
Dylan



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Trouble with SaveAs .csv

You are correct - I didn't look closely enough.

you have to do more than specify the extension

ActiveWorkbook.SaveAs Filename:= _
"F:\PRICEUPLD\price.csv", FileFormat:=xlCSV


--
Regards,
Tom Ogilvy


" wrote:

Thanks Tom,

The extra data appears to be formatting data along with the VBA code.
It seems that the file is not truly getting saved as a .csv file, since
when I look at it in notepad there are no commas.

Thanks for the link to Chris Pearson's code. I need to go through it
in more detail, but it looks like I'll be able to modify it for my
needs.

Dylan

I appreciate the link to Chris Pearson's code.

Tom Ogilvy wrote:
I can't imagine what the extraneous data might be.

But to have more control you might look at Chip Pearson's code.

http://www.cpearson.com/excel/imptext.htm import/export text files

--
Regards,
Tom Ogilvy


" wrote:

Hello,

I am very new to programming with VBA in Excel, but am trying to learn
as much as possible, and these groups are certainly an excellent
resource for that. So here is my problem.

Each day I need to:
1) Open up an Excel file linked to several other files
2) Break the links to the other files
3) Delete a column
4) Save the file as an .xls file with the current date
5) Save a second copy as a .csv file (with same file name each day)
6) Upload .csv file to our database

I've been trying to break this down into steps and write code for each
step as I learn it. So far I've done steps 2-5 with the code below.

Sub SavePriceUpload()

'

' Comment: Save as Date

' Created on 7/27/2006

'

Sheets("Sheet1").Activate

Cells.Select

Selection.Copy

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _

:=False, Transpose:=False



Columns("H:H").Select

Range(Selection, Selection.End(xlToRight)).Select

Selection.Delete Shift:=xlToLeft



dtmDate = Date



strMonth = Month(Date)

strDay = Day(Date)

strYear = Right(Year(Date), 2)



ActiveWorkbook.SaveAs Filename:= _

"F:\PRICEUPLD\Price\PriceUpload" & strMonth & "-" & strDay & "-" &
strYear & ".xls"



ActiveWorkbook.SaveAs Filename:= _

"F:\PRICEUPLD\price.csv"



End Sub

Everything seems to work great, except when I try to upload the .csv
file to my database it fails. If I open the .csv file in a text editor
I can see that there is a bunch of other info that doesn't show up when
I open the csv file in Excel, like my VBA code. So any ideas how I can
do this without the extraneous data. Let me know if I'm going about
this in entirely the wrong way.

Thanks,
Dylan




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Trouble with SaveAs .csv

Excellent! Thanks Tom.

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
Having trouble getting 'Local' parameter in SaveAs method to work [email protected] Excel Programming 1 December 21st 05 09:34 PM
Using the SaveAs in VBA caldog Excel Programming 2 October 5th 05 01:05 AM
More SaveAs trouble Shawn Shuler[_2_] Excel Programming 1 August 9th 04 05:48 AM
SaveAs... Chris Gorham[_3_] Excel Programming 2 December 27th 03 04:50 PM
SaveAs Dave Peterson[_3_] Excel Programming 1 September 12th 03 12:44 AM


All times are GMT +1. The time now is 05:25 PM.

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

About Us

"It's about Microsoft Excel"