Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 30th, 2009, 10:02 AM
Registered User
 
Join Date: Sep 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Export to spool // Format issue

Hello,

I try to export a selection of data from excel to a specified spool in format .txt , but unfortunately, my file appears with "," and not";" as requested (even after having modified my file in .CSV) and my data finish by ,,,,,,,,,,,
So I can not use it in an other software.

If somebody meet the same problem.



Partial Code :

ActiveWorkbook.SaveAs Filename:="K:/NAME", _
FileFormat:=xlCSV, CreateBackup:=True, Local:=True

ActiveWorkbook.SaveCopyAs Filename:="K:/NAME.txt"


ActiveWorkbook.Sheets.Select
Selection.Replace What:=",", Replacement:=";", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False




I have :


30/09/09,Client1,40148,100.0,100.0,name1,,,name4,,,,,,,,
,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,




,,,,,,,,,,,,,,,,





Thanks for your help.

Julien
 
Old September 30th, 2009, 10:13 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi Julien

Excel by default saves the file as comma separated; this is because of the regional settings (Comma is the list separator). You can try changing the same from Control Panel-->Regional Options-->Numbers-->List Separator to ';'

Since you are replacing comma with ";' in Excel it will replace the 'actual' comma's in Text and not the delimiters. Instead you can try replacing the Comma's with some unusual sequence of characters "$#$#$#" etc and save the Excel as CSV. Now you can open the CSV using Open command / FileSystemObject and replace

1. Comma's with Semicolon
2. $#$#$# with Comma

You can also try this link (http://www.cpearson.com/excel/ImpText.aspx)

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
export to txt format mallick_kuet Crystal Reports 0 January 21st, 2007 02:50 AM
export in txt format mallick_kuet C# 2005 0 January 20th, 2007 06:24 AM
export in txt format mallick_kuet BOOK: Professional Crystal Reports for VS.NET 0 January 20th, 2007 05:22 AM
export data to .dat format chacquard Access VBA 6 January 10th, 2005 03:50 PM
Export in PDF Format MER78 BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 October 9th, 2004 11:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.