Export to Text file.

Please help me.

I writen this VBA code for export range to Text file.



--------
Option Explicit

Private Sub ExportButton_Click()
Dim fHand As Long, expCode As Variant

fHand = FreeFile
Open ExportName For Output As fHand

Write #fHand, TextBox    'TextBox included text "[Example]"
Write #fHand, "key_temp="

For Each expCode In Range(CodeRef)
    Write #fHand, 1, expCode
Next expCode

Close fHand
End Sub


--------
I want export content should like this

[Example]
key_temp=1,000690;1,000063;1,000022;1,000829;0,600001;0,600005;0,000001;1,39
9001;


--------
But now is this.

"[Example]"
"key_temp="
1,"000633"
1,"000830"
1,"000056"
1,"000407"
1,"000806"
1,"000860"
1,"000881"
1,"000850"
1,"000928"
1,"000717"


--------
How to remove the quotation mark?
how i export the ';' semicolon mark?


Thanks a lot.


0
Cactus
2/22/2006 4:55:40 PM
excel 39879 articles. 2 followers. Follow

2 Replies
725 Views

Similar Articles

[PageSpeed] 52

Maybe this'll help:

Option Explicit
Private Sub ExportButton_Click()
    Dim fHand As Long
    Dim expCode As Range
    Dim ExportName As String
    Dim myStr As String
    
    ExportName = "C:\my documents\excel\test.out"
    
    fHand = FreeFile
    Open ExportName For Output As fHand
    
    Print #fHand, "[Example]"  'change this back
    Print #fHand, "key_temp=";
    
    myStr = ""
    For Each expCode In Range("CodeRef").Cells
        myStr = myStr & ";1," & Format(expCode.Value, "000000")
    Next expCode
    
    myStr = myStr & ";"
    myStr = Mid(myStr, 2)
    Print #fHand, myStr
    
    Close fHand
End Sub


Cactus wrote:
> 
> Please help me.
> 
> I writen this VBA code for export range to Text file.
> 
> --------
> Option Explicit
> 
> Private Sub ExportButton_Click()
> Dim fHand As Long, expCode As Variant
> 
> fHand = FreeFile
> Open ExportName For Output As fHand
> 
> Write #fHand, TextBox    'TextBox included text "[Example]"
> Write #fHand, "key_temp="
> 
> For Each expCode In Range(CodeRef)
>     Write #fHand, 1, expCode
> Next expCode
> 
> Close fHand
> End Sub
> 
> --------
> I want export content should like this
> 
> [Example]
> key_temp=1,000690;1,000063;1,000022;1,000829;0,600001;0,600005;0,000001;1,39
> 9001;
> 
> --------
> But now is this.
> 
> "[Example]"
> "key_temp="
> 1,"000633"
> 1,"000830"
> 1,"000056"
> 1,"000407"
> 1,"000806"
> 1,"000860"
> 1,"000881"
> 1,"000850"
> 1,"000928"
> 1,"000717"
> 
> --------
> How to remove the quotation mark?
> how i export the ';' semicolon mark?
> 
> Thanks a lot.

-- 

Dave Peterson
0
petersod (12004)
2/22/2006 5:48:05 PM
Dave

Thanks.



0
Cactus
2/22/2006 6:14:37 PM
Reply:

Similar Artilces:

Contacts export display X400 not SMTP
Hi all, I'm not sure if this behavior is by default or not, but when my users try to export their contacts to an Excel file, any internal (domain) contacts show the X400 address rather than the SMTP address. Is there a way to change this? I've read some about VB scripts with CDO or something, but hoping there is an alternate way. Thanks Mike -- what version Exchange? -- Susan Conkey [MVP] "Mike W." <wallmr_snowpam@gmailDOTC0M> wrote in message news:iQ72h.553254$Pi2.240974@fe08.news.easynews.com... > Hi all, > > I'm not sure if this behavio...

Export to XML exports single row only
What I did: On XML source panel of Excel 2007 added XML map, mapped to columns using ranges (i. e. A1:A1825), selected “Export” from “Developer” tab in the ribbon. Result: Output XML file contains only one record (first row from the worksheet) I’ve done this numerous times in Excel 2003 with no problem. What happens?? Please help! Thanks, Eugene ...

Text disappears when format changed in MS Word (Office X)
I save Word documents in Mac Word 5.1 format while using Office X. Sometimes when I resave, the format changes to the generic Microsoft Office document format. After this happens and I open the document, the text of the document is missing entirely. I an using Panther 10.3.3. Any ideas? Thank you. James Costello ...

winmail.dat
When we send attachments to people they show up on their ends as winmail.dat files. We are using Outlook 2000 on the XP platform. I researched and can't seem to come up with a solution. We are not using RTF (rich text format) and that seems to be the only configuration associated with this problem that I can find. We are using plain text and it still happens when we forward an email w/ an attachment and reset it to send via plain text. Any help would be appreciated. Thank you. Use plain text or html format and disable Word as your e-mail editor. If it still occours, it could b...

Export / Import Security
Ok, so I have setup my test environment again. Now I have to create security all over from scratch to define what will be used in production. Is there a way to export from the test environment and then import it into the newly upgraded installation? In both cases security has been/will be completely removed from the 8.0 install (restored on new server) before being upgraded to version 10. Dear, Security will be upgraded upon upgrading GP from GP 8.0 SP5 to GP 10.0. Converting the Security structure from GP 8.0 to 10.0 will not be an easy task. Regards, -- Mohammad R. Daoud MCP, MCBM...

Exporting Sent Email Addresses from Entourage
Version: 2004 Operating System: Mac OS X 10.4 (Tiger) Processor: Power PC Hello! I'm trying to export email addresses from an employee's Entourage, but would like to include email addresses in his "Sent Items" folder. Is there a way to export these email addresses aside from exporting the "MBOX" file, which has all the email content as well? Thanks in advance! On 3/12/08 8:49 AM, in article ee9381d.-1@webcrossing.caR9absDaxw, "Quinlisk@officeformac.com" <Quinlisk@officeformac.com> wrote: > I'm trying to export email addresses from an emplo...

Recovering Files
Is there any possible way where you can recover a file that has been lost, and when it appeared in the autorecover box wasn't saved? Thanks for your help. You could be lucky and it will be in your temp folder. Type %temp% in the address bar in Windows Explorer. Look for files that have a pub prefix, change the .tmp extension to .pub. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "kate" <kate@discussions.microsoft.com> wrote in message news:3B2E96A9-AED1-4524-B0CF-E4A2EDDF94CF@microsoft.com... > Is there an...

How do I email a hyperlink to a program file with a website as a parameter
Hi all, We're trying to email a hyperlink to a program file on a persons C: drive which by itself works fine. But when we append a parameter in the form of http://website.com then it thinks the entire link is a website and chokes. What we're trying to do start a Citrix ICA file from an email and feed it a dynamic website. The full link is "C:\Program Files\Citrix\ICA Client\wfica32.exe" \\server\share\IE.ICA /param:"HTTP://website.com" I want the link to be just as is but Outlook changes the backslashes to forward slashes and generally mucks it up. ...

how can I get Outlook (not Outlook Express) to be used to send files from my computer
How can I get Outlook (not Outlook Express) to be used to send files from my computer? I've just started using my new Compaq Presario 3000 laptop running XP Home. Each time that try to send a file by right clicking on it and selecting Mail Reciepient the mail is sent via Outlook Express and not Outlook. THis is a problem for me as I do niot use Outlook Express for anything but Newsgroup reading. The other problem is that I want a record of having sent the file in my Outlook Sent Mail folder. On my old computer the files went through Outlook and not Outlook Express I've checked th...

Export item ID?
Hi there. Having resolved my previous EMS Data import issues, I have now moved on to more complicated things (importing supplier lists, aliases etc). However, these operations require the item ID for each item - something I don't have. Is there some way I can export these from the database so I know what item ID corresponds to each item. I have run a query in Administrator (select itemlookupcode, ID from item) which tells me this, but I haven't worked out how to export this out to a spreadsheet. Any help would be appreciated, cheers After running your query goto File menu and Export....

One money file, 2 computers
I am new to money. I want to be able to access money both from work and at home. To facilitate this, I have a portable Hard Drive. I installed money to it at home, installed money to it at work (stoopid registry) pointed both instances to a single money file. Now, when I run it at home, everything is fine. When I run it at work I get a critical file is missing error. I reinstall at work and everything is fine again. I go home and voila! A critical file is missing error! <grrr /> How do I skin this cat? Is there a better way of doing this? I won't be purchasing money un...

How do I link a picture to a text cell
Hi everyone, I must warn you all I am fairly new to excel so please reply in terms a novice would be able to understand, Thanks :) This is what I am trying to achieve: I have a list box with 10 possible selections, lets say for example that 'Apple' was a selection, If I choose 'Apple' I would like a picture of an apple to appear in a different cell range, and if I was to choose 'Pear' I would like the 'Apple' picture to be replaced by a 'Pear' picture. Does this make sense ? :confused: Any help would be much appreciated. Mark...... :) -- Chippy_...

Formating text in a text field
Does anyone have any ideas on how to add a blank space between fields being mapped to a text field? I have 4 fields I want to pull into one field with a space between each one. No HTML code works, is there a way to create the blank space So my workflow will map 3-4 fields to a text field but I would like a space between the values. insert value 1 (no problem) need to insert a space insert value 2 need to insert space insert value 3 Denzel Workflow assembly can deliver the functionallity you need. Check SDK for a sample. Hope this helps, Jevgenij "Denzel" <Denzel@discuss...

Is there a way to make a staircase text effect?
Is there a way to create a string of letters that will remain erect when the object they are part of is rotated? I want to create a staircase effect where the letters look like they are sitting on the steps of a staircase and be able to alter how steep the staircase is and have the letters remain vertical. Thanks -- Email: Usenet-20031220 at spamex.com (11/09/04) Nothing built-in per se. You'd have to create separate shapes that belong to a group, and do some ShapeSheet programming. The shape's could then "anti-rotate" relative to the group (Angle = - GroupSheet!Angle...

Exporting email in Outlook Express
I am unable to export all emails in Outlook Express. First it had an error message mentioning MAPI so i followed the instructions on Microsoft Knowledge Base to install Windows Messaging - now when i try to export the following error message is: MAPISP32 caused an invalid page fault in module KERNEL32.DLL at 0187:bff7b9a6. Does anyone know what this means? tania jackson <tania@realtime-bs.com> wrote: > I am unable to export all emails in Outlook Express. Ask in an Outlook Express newsgroup. -- Brian Tillman Smiths Aerospace 3290 Patterson Ave. SE, MS 1B3 Grand Rapid...

Exporting to Powerpoint
I have a small table in Excel that I am trying to export to PowerPoint, for some inexplicable reason one column was always missing even though it was specified in the range which the Macro is supposed to export. My manager is the only was able to see the value in that column and no other can replicate his success. Do you know any reason for this? We are all looking at the exact same file, why could he see something that the rest of us cannot? Tao, Why don't you simply copy and paste the whole table into a Powerpoin slide? Joh -- Message posted from http://www.ExcelForum.com...

Export Image Package
I have an access application that has stored .JPG images within the database as a "Package". How can I export the image back to a normal .jpg file so that it can be read by a normal (non ole server) imaging application? ...

Missing Report Manager help file
Greetings: I run Windows XP home and Office XP Professional. Sometime last year I installed Report Manager add-in for Excel. In March 2005 I had to do a reinstall. Since then, when I click on View>Report>Manager>help I get a message stating that the XLMAIN8.HLP file cannot be found. The utility is checked in the Add-On dialog box. As I still have the download in the My Downloads folder I have even tried reinstalling the utility again but still the help file remains lost somewhere. Can someone offer some advice on what to do next? Where could the file have gone? How can I get it back...

WMP Subtitles When Playing A File
When I Play an MPEG file is some of my other Media Players, sunch as BlazeDVD 5.1, subtitles are shown when I play the file. However, when I play the file in WMP 11.0, the subtitles are not shown. I know the subtitles are in the video stream because they show up in other players but why not WMP? Are you supposed to be able to turn the subtitles off and on? I have read on other forums that the subtitles are embedded in the video. But, how can that be? In one player they show up and another they don't. On Mon, 30 Nov 2009 11:09:01 -0800, Ray <Ray@discussions.microsoft.c...

best way to file away GP documents
Hi, I am wondering what is the best way to file away reports generated by Great Plains such as posting journals and payment vouchers(maybe according to audit trail codes). does it make a difference if you post by transaction or by batch for filling purposes. Thank you Usually people put them all in big piles (of binders sorted by series if they are a little more organized).....then once every few months (or for those with bigger offices, years) they realize they have never used these printouts for anything and proceed to throw them out. IMHO it's much more important to spend the e...

Export registry key
Hi, Is there an API to Export and Extract a registry key in a text format ? I need to simulate the operation that is done by the user of exporting a key (and creating a .reg file in a text format). I do not want to use RegSaveKey/RegRestorekey which work in a binary format. Yoav. I believe you will have to do this yourself. There is no Automation or exported function interface to RegEdit, and that .Reg file concept is a feature of that program. However, it shouldn't be terribly difficult to do this, using RegEnumKeyEx and RegEnumValue or the CRegKey class, use a CStdioFile object...

Export from Excel to Word
I have a 20 page Excel document that has a LOT of formating involved, it is text not data. Is there a way that I get it into Word without having to redo all the formatting? It is 11x17, landscape. Yes: Select the area you wish to copy. While holding the SHIFT key pull-down: Edit > Copy Picture... In the Word document, just paste. Because you have pasted a picture, the formatting will be preserved. Also because its a picture, yo can re-size it as you choose. -- Gary's Student "kath0178" wrote: > I have a 20 page Excel document that has a LOT of formating inv...

Backup and restore entire Outlook File
I have Win XP and Outlook 2002. Using Windows Explorer I copied an Outlook.pst file by locating the file in Windows explorer and using Copy because the Outlook in that user file doesn't have the File, Backup option. I copied the file to a CD-R. I then took that CD-R to my laptop and imported from the file my Contacts. When finished I had all of the contacts data, but did not have any of the setup work I had done in Current Views, Master Categories, etc. How to I copy the file so that I get all of that set up info? The only way I can find to get the data onto the Laptop is t...

Reverse of export to database
Ave, I would like to generate a Visio drawing starting from an Access database which contains the results of an 'export to database' of an existing drawing. I found import possibilities from Excel, csv, txt files, but not from databases. I'm using Visio 2002 Professional. Greetings, Are you trying to import the data from the database tables or the database schema? If it is the database schema, run the Database modeling template (File \ New \ Database \ Database model diagram) If you want to get the data, try the "Link to Database" dialog (Tools \ Macros \ Visio Extras...

auto text
im now using windows 7 and am trying to figure out how to have formatted text phrases that i use over and over again in email replys in outlook to automatically fill in so i dont have to type them all out every time. used to be auto text but now i cant figure out how it works in the windows 7 system. any help is greatly appreciated. Assuming your using the same version of Office / Outlook as before nothings changed by using Win7 "skyler" <skyler@discussions.microsoft.com> wrote in message news:24E7547A-9623-4499-95A7-60B3AAC5D704@microsoft.com... > im no...