Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

export a non defined table as txt or cvs by VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
snaggy^^ - 22 Jan 2006 11:14 GMT
I have in my "Summary" page a table which has four coloumns and an undefined
number of rows. There's nothing under this table, so the firs white line
means the end of it. I need a macro to export this table as a kind of backup,
in a txt o cvs file.

When i search the help file for it, i find just XML exporting, and mapping
(by the way i don't understand what it is)

bye
Ron de Bruin - 22 Jan 2006 11:36 GMT
Hi snaggy

Try this that copy the csv in C:\

Sub Save_ActiveSheet_CSV_File()
   Dim wb As Workbook
   Dim strdate As String
   Dim Fname As String
   strdate = Format(Now, "dd-mm-yy h-mm-ss")
   Fname = "C:\Part of " & ThisWorkbook.Name _
         & " " & strdate & ".csv"
   Application.ScreenUpdating = False
   ActiveSheet.Copy
   Set wb = ActiveWorkbook
   With wb
       .SaveAs Fname, FileFormat:=xlCSV
       .Close False
   End With
   Application.ScreenUpdating = True
End Sub

Signature

Regards Ron de Bruin
http://www.rondebruin.nl

>I have in my "Summary" page a table which has four coloumns and an undefined
> number of rows. There's nothing under this table, so the firs white line
[quoted text clipped - 5 lines]
>
> bye
snaggy^^ - 22 Jan 2006 13:03 GMT
That was perfect!
Du you know how to extract the path of the current xls so that he can save
the CVS in the same directory?

thanks a lot

> Hi snaggy
>
[quoted text clipped - 26 lines]
> >
> > bye
Tushar Mehta - 22 Jan 2006 13:45 GMT
Search XL VBA help for 'path' (w/o the quotes).

Signature

Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

> That was perfect!
> Du you know how to extract the path of the current xls so that he can save
> the CVS in the same directory?
>
> thanks a lot

{snip}
Ron de Bruin - 22 Jan 2006 14:21 GMT
If you have try Tushar's advise your code looks like this

Sub Save_ActiveSheet_CSV_File_2()
   Dim wb As Workbook
   Dim strdate As String
   Dim Fname As String
   strdate = Format(Now, "dd-mm-yy h-mm-ss")
   Fname = ActiveWorkbook.Path & "\Part of " & ThisWorkbook.Name _
           & " " & strdate & ".csv"
   Application.ScreenUpdating = False
   ActiveSheet.Copy
   Set wb = ActiveWorkbook
   With wb
       .SaveAs Fname, FileFormat:=xlCSV
       .Close False
   End With
   Application.ScreenUpdating = True
End Sub

Signature

Regards Ron de Bruin
http://www.rondebruin.nl

> That was perfect!
> Du you know how to extract the path of the current xls so that he can save
[quoted text clipped - 32 lines]
>> >
>> > bye
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.