Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default XLS to CSV conversion

Hi evreone, I have a Excel document and I wish to do the following :

I want to make a macro that automatically saves a copy of the XL
document in CSV format and updates the CSV document whenever the XL
one is saved.

The only problem is that I am a total n00b at Excel VBA programming...


Can anyone help me out and point me toward the right direction ??

THX

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default XLS to CSV conversion

Anyone

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default XLS to CSV conversion

You could try this:

This part goes behind the ThisWorkbook module:

Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Application.OnTime Now + TimeSerial(0, 0, 1), "savecsvnow"
End Sub

This part goes in a general module:

Option Explicit
Sub SaveCSVNow()

Dim wks As Worksheet
Dim newWks As Worksheet

Set wks = ThisWorkbook.Worksheets("sheet1")

wks.Copy 'to a new workbook
Set newWks = ActiveSheet
With newWks
With Application
.ScreenUpdating = False
.DisplayAlerts = False
End With
.Parent.SaveAs Filename:=ThisWorkbook.Path & "\mycsvfilenamehere.csv", _
FileFormat:=xlCSV
.Parent.Close savechanges:=False
With Application
.DisplayAlerts = True
.ScreenUpdating = True
End With
End With
End Sub

Adjust the worksheet name accordingly and the .csv file, too.


If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm




"border21 <" wrote:

Hi evreone, I have a Excel document and I wish to do the following :

I want to make a macro that automatically saves a copy of the XLS
document in CSV format and updates the CSV document whenever the XLS
one is saved.

The only problem is that I am a total n00b at Excel VBA programming...

Can anyone help me out and point me toward the right direction ??

THX !

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson

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
Conversion to value between 1 to 10 only! wilchong via OfficeKB.com New Users to Excel 5 May 23rd 08 02:10 PM
ESN conversion jay-rod Excel Worksheet Functions 2 April 29th 07 11:36 PM
pdf conversion Pat Excel Worksheet Functions 2 July 1st 05 12:53 AM
Between conversion Dan Wilson Excel Worksheet Functions 0 March 13th 05 03:02 PM
hex conversion Ruchi[_2_] Excel Programming 2 October 31st 03 04:41 AM


All times are GMT +1. The time now is 09:00 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"