Skip to main content

Conas sonraí Excel (roghnú nó bileoga) a easpórtáil chuig comhaid Téacs in Excel?

Má iarrtar ort leabhar oibre a sheachadadh i bhformáid an chomhaid téacs, ní mór duit an leabhar oibre a thiontú ina chomhaid téacs. Agus tabharfaidh an t-alt seo dhá mhodh isteach duit chun sonraí Excel a easpórtáil i gcomhaid téacs go héasca.

Easpórtáil bileog amháin go comhad téacs in Excel

De réir réamhshocraithe, sábhálfar na sonraí Excel mar leabhair oibre i bhformáid . XLSX. Mar sin féin, is féidir linn bileog oibre de leabhar oibre atá ann cheana a easpórtáil mar chomhaid téacs leis an Sábháil Mar gné. Déan mar a leanas le do thoil:

1. Aistrigh go dtí an bhileog oibre a easpórtálfaidh tú chuig comhad téacs, agus cliceáil Comhad (nó Cnaipe oifige)> Sábháil Mar.

2. San oscailt Sábháil Mar bosca dialóige, roghnaigh an fillteán ceann scríbe a shábhálfaidh tú an comhad téacs easpórtáilte isteach, ainmnigh an comhad sa Ainm comhaid bosca, agus ansin roghnaigh an Téacs Unicode (* .txt) ón Ach amháin mar chineál liosta anuas. Féach an pictiúr:
easpórtáil go téacschomhad le gné Save As

3. Ansin popfaidh sé suas dhá bhosca dialóige rabhaidh ag iarraidh ort gan ach bileog oibre gníomhach a easpórtáil mar chomhad téacs agus aon ghnéithe neamh-chomhoiriúnacha a fhágáil amach le comhad téacs. Cliceáil OK cnaipe agus Is ea cnaipe i ndiaidh a chéile.

Ansin déantar na sonraí sa bhileog oibre gníomhach a onnmhairiú mar chomhad téacs nua.

nótaí: An Sábháil Mar ní féidir leis an gceannas ach sonraí de bhileog oibre ghníomhach a easpórtáil mar chomhad téacs. Más mian leat sonraí uile an leabhair oibre iomláin a easpórtáil, ní mór duit gach bileog oibre a shábháil mar chomhad téacs ina n-aonar.


Roghnú easpórtála (nó colún amháin) chuig comhad téacs le VBA

Is féidir leis an gcód VBA seo a leanas cabhrú leat na sonraí raon roghnaithe (mar shampla colún amháin) a easpórtáil chuig an gcomhad téacs, déan mar seo le do thoil:

1. Coinnigh síos an ALT + F11 eochracha, agus osclaíonn sé an Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

2. cliceáil Ionsáigh > Modúil, agus greamaigh an cód seo a leanas i bhFuinneog an Mhodúil.

VBA: roghnú easpórtála nó bileog oibre iomlán chuig an gcomhad téacs

Sub ExportRangetoFile()
'Update 20130913
Dim wb As Workbook
Dim saveFile As String
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set wb = Application.Workbooks.Add
WorkRng.Copy
wb.Worksheets(1).Paste
saveFile = Application.GetSaveAsFilename(fileFilter:="Text Files (*.txt), *.txt")
wb.SaveAs Filename:=saveFile, FileFormat:=xlText, CreateBackup:=False
wb.Close
Application.CutCopyMode = False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

3. Ansin brúigh F5 eochair chun an cód seo a rith. Agus ansin roghnaigh an raon sonraí a theastaíonn uait a easpórtáil sa bhosca dialóige aníos, agus cliceáil ar an OK cnaipe, féach ar an scáileán:
Roghnaigh colún amháin le honnmhairiú mar chomhad téacs

4. Agus anois i mbosca dialóige Save As eile, sonraigh ainm don chomhad téacs seo agus fillteán chun an comhad seo a chur ann, agus cliceáil ar an Sábháil cnaipe.


Roghnú easpórtála (nó colún amháin) chuig comhad téacs le Kutools for Excel

An Sábháil Mar is féidir le ceannas na sonraí go léir a easpórtáil sa bhileog oibre gníomhach mar théacs. Cad a tharlaíonn má dhéantar na sonraí go léir de bhileoga oibre neamhghníomhacha sonraithe, nó cuid de na sonraí i mbileog oibre a easpórtáil mar chomhad téacs? Kutools le haghaidh Excel's Raon Easpórtála go Comhad is féidir le fóntais cabhrú linn na sonraí i roghnú mar chomhad téacs a easpórtáil agus a shábháil go héasca.  

Kutools le haghaidh Excel - Pacáilte le breis agus 300 uirlis riachtanach le haghaidh Excel. Bain sult as triail iomlán 30-lá SAOR IN AISCE gan aon chárta creidmheasa ag teastáil! Íoslódáil anois!

1. Roghnaigh an ghlao a easpórtálfaidh tú chuig comhad téacs (inár gcás féin, roghnaímid Colún A), agus cliceáil Kutools Plus > Iompórtáil / Export > Raon Easpórtála go Comhad, féach ar an scáileán:
Excel addin: roghnú onnmhairithe go comhad téacs

2. sa Raon Easpórtála go Comhad bosca dialóige, déan mar a thaispeántar thíos an scáileán:
Excel addin: roghnú easpórtála chuig comhad téacs
(1) Seiceáil an Téacs Unicode rogha sa formáid comhad alt;
(2) Seiceáil an rogha Sábháil na luachanna iarbhír nó Sábháil luachanna mar a thaispeántar an rogha ar an scáileán de réir mar a theastaíonn uait sa rannán Roghanna Téacs;
(3) Sonraigh an fillteán ceann scríbe a shábhálfaidh tú an comhad téacs easpórtáilte;
(4) Cliceáil ar an Ok cnaipe.

3. Ainmnigh an comhad téacs a onnmhairítear sa bhosca dialóige oscailte nua, agus cliceáil ar an Ok cnaipe.
ainmnigh an comhad téacs a onnmhairítear

Agus ansin rinneadh an roghnúchán (Colún A roghnaithe) a onnmhairiú mar chomhad téacs agus a shábháil isteach san fhillteán sonraithe.

Kutools le haghaidh Excel - Supercharge Excel le níos mó ná 300 uirlisí riachtanacha. Bain sult as triail iomlán 30-lá SAOR IN AISCE gan aon chárta creidmheasa ag teastáil! Get sé anois


Easpórtáil iliomad bileoga chun comhaid téacs a scaradh in Excel

Uaireanta, b’fhéidir go mbeidh ort iliomad bileoga oibre a easpórtáil chuig comhaid téacs iolracha in Excel. B’fhéidir go bhfuil an ghné Save As rud beag tedious! Ná bí buartha! Kutools le haghaidh Excel's Leabhar Oibre Scoilt soláthraíonn fóntais bealach oibre éasca d’úsáideoirí Excel chun iliomad bileoga oibre a onnmhairiú chuig go leor comhaid téacs ar leithligh le roinnt cad a tharlaíonn. 

Kutools le haghaidh Excel - Pacáilte le breis agus 300 uirlis riachtanach le haghaidh Excel. Bain sult as triail iomlán 30-lá SAOR IN AISCE gan aon chárta creidmheasa ag teastáil! Íoslódáil anois!

1. cliceáil Kutools Plus > Leabhar OibreLeabhar Oibre Scoilt. Féach an pictiúr:
Excel addin: leatháin iolracha a easpórtáil chuig comhaid téacs

2. Sa bhosca dialóige tosaigh Leabhar Oibre Scoilt, déan mar a leanas:
Excel addin: leatháin iolracha a easpórtáil chuig comhaid téacs
(1) Seiceáil na bileoga oibre a easpórtálfaidh tú chuig comhaid téacs ar leithligh sa Ainm an leabhair oibre alt;
(2) Seiceáil an Sonraigh formáid sábháil rogha, agus ansin roghnaigh an Téacs Unicode (* .txt) ón liosta anuas thíos, féach an pictiúr ar chlé:
(3) Cliceáil ar an Scoilt cnaipe.

3. Agus ansin sa bhosca dialóige aníos Browse For Folder, roghnaigh an fillteán ceann scríbe a shábhálfaidh tú comhaid téacs a onnmhairítear isteach ann, agus cliceáil ar an OK cnaipe.

Go dtí seo rinneadh gach bileog oibre shonraithe a onnmhairiú mar chomhad téacs ar leithligh agus a shábháil isteach san fhillteán sonraithe.

Kutools le haghaidh Excel - Supercharge Excel le níos mó ná 300 uirlisí riachtanacha. Bain sult as triail iomlán 30-lá SAOR IN AISCE gan aon chárta creidmheasa ag teastáil! Get sé anois

Maisigh go héasca gach bileog mar chomhad PDF / text / csv nó leabhar oibre ar leithligh in Excel

De ghnáth is féidir linn bileog oibre gníomhach a shábháil mar chomhad .pdf ar leithligh, comhad .txt, nó comhad .csv leis an ngné Save As. Ach Kutools do Excel's Leabhar Oibre Scoilt is féidir le fóntais cabhrú leat gach leabhar oibre a shábháil go héasca mar chomhad nó leabhar oibre PDF / TEXT / CSV ar leithligh in Excel.


leabhar oibre scoilte roinnte pdf 1

Kutools le haghaidh Excel - Supercharge Excel le níos mó ná 300 uirlisí riachtanacha. Bain sult as triail iomlán 30-lá SAOR IN AISCE gan aon chárta creidmheasa ag teastáil! Get sé anois


Taispeántas: easpórtáil sonraí Excel (roghnú nó bileoga) chuig comhaid Téacs in Excel


Kutools le haghaidh Excel: Breis is 300 uirlis láimhe ar do mhéar! Cuir tús le do thriail saor in aisce 30-lá gan aon srianta gné inniu. Íosluchtaigh Anois!

Airteagail ghaolmhara:

Uirlisí Táirgiúlachta Oifige is Fearr

🤖 Kutools AI Aide: anailís sonraí a réabhlóidiú bunaithe ar: Forghníomhú Chliste   |  Gin Cód  |  Cruthaigh Foirmlí Saincheaptha  |  Anailís a dhéanamh ar Sonraí agus Cairteacha a Ghin  |  Feidhmeanna Kutools a agairt...
Gnéithe Coitianta: Faigh, Aibhsigh nó Aithnigh Dúblaigh   |  Scrios Sraitheanna Bána   |  Comhcheangail Colúin nó Cealla gan Sonraí a Chailleadh   |   Babhta gan Foirmle ...
Cuardaigh Super: Ilchritéir VLookup    VLookup Illuachanna  |   VLookup Trasna Ilbhileoga   |   Amharc doiléir ....
Liosta anuas Casta: Go tapa Cruthaigh Liosta Anuas   |  Liosta anuas Cleithiúnach   |  Liosta Buail Isteach Ilroghnacha ....
Bainisteoir Colún: Cuir Líon Sonrach Colún leis  |  Colúin Bog  |  Scoránaigh Stádas Infheictheachta na gColún Ceilte  |  Déan comparáid idir Raonta & Colúin ...
Gnéithe Réadmhaoin: Fócas Eangaí   |  Amharc Dearaidh   |   Barra Mór na Foirmle    Leabhar Oibre & Bainisteoir Bileog   |  Leabharlann Acmhainní (Uaththéacs)   |  Piocálaí Dáta   |  Comhcheangail Bileoga Oibre   |  Criptigh/Díchriptigh Cealla    Seol Ríomhphost trí Liosta   |  Scagaire Super   |   Scagaire Speisialta (scagaire trom/iodálach/stailc tríd...) ...
Barr 15 Uirlisí12 Téacs uirlisí (Cuir Téacs, Bain Carachtair,...)   |   50 + Cairt cineálacha (Cairt Gantt,...)   |   40+ Praiticiúil Foirmlí (Ríomh aois bunaithe ar lá breithe,...)   |   19 Insertion uirlisí (Cuir isteach Cód QR, Ionsáigh Pictiúr ón gCosán,...)   |   12 Tiontú uirlisí (Uimhreacha le Focail, Comhshó Airgeadra,...)   |   7 Cumaisc & Scoilt uirlisí (Sraitheanna Comhcheangail Casta, Cealla Scoilt,...)   |   ... agus eile

Supercharge Do Scileanna Excel le Kutools le haghaidh Excel, agus Éifeachtúlacht Taithí Cosúil Ná Roimhe. Kutools le haghaidh Excel Tairiscintí Níos mó ná 300 Ardghnéithe chun Táirgiúlacht a Treisiú agus Sábháil Am.  Cliceáil anseo chun an ghné is mó a theastaíonn uait a fháil ...

Tuairisc


Tugann Tab Oifige comhéadan Tabbed chuig Office, agus Déan Do Obair i bhfad Níos Éasca

  • Cumasaigh eagarthóireacht agus léamh tabbed i Word, Excel, PowerPoint, Foilsitheoir, Rochtain, Visio agus Tionscadal.
  • Oscail agus cruthaigh cáipéisí iolracha i gcluaisíní nua den fhuinneog chéanna, seachas i bhfuinneoga nua.
  • Méadaíonn do tháirgiúlacht 50%, agus laghdaíonn sé na céadta cad a tharlaíonn nuair luch duit gach lá!
Comments (19)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
How would I amend the code for Export selection (or one column) to text file with VBA to autofill the filename with the contents of cell B2?
thanks
This comment was minimized by the moderator on the site
Hi,This is great, thanks a lot.
How would I alter the code for Export selection (or one column) to text file with VBA to auto fill the filename with the contents of cell B2?
This comment was minimized by the moderator on the site
Hi, this code is very useful for me. So thank you very much.
I want to ask that: When i'm using this code, a new line append automatically at the end of the txt content.
Can you help me about preventing this by vba?
This comment was minimized by the moderator on the site
hi guys, i used that code:
Sub ExportRangetoFile()
'Update 20130913
Dim wb As Workbook
Dim saveFile As String
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set wb = Application.Workbooks.Add
WorkRng.Copy
wb.Worksheets(1).Paste
saveFile = Application.GetSaveAsFilename(fileFilter:="Text Files (*.txt), *.txt")
wb.SaveAs Filename:=saveFile, FileFormat:=xlText, CreateBackup:=False
wb.Close
Application.CutCopyMode = False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

and have working, but i need to savea column with cells that contain the function"concatenate", and when i play the vba code, and i save the .TXT file, only what appears it's #REF. how can i to fix it? cause i need the data that appears on that cells?
This comment was minimized by the moderator on the site
Has anyone been able to figure this out? I am having the same issue.
This comment was minimized by the moderator on the site
HELLO
THANK YOU FOR YOUR VBA CODE
SOMETIMES ON CERTAIN TEXT THERE IS "TEXT" IN EXPORT .TXT
THANK YOU FOR WHY
This comment was minimized by the moderator on the site
Thanks for the awesome piece of VBA code to export data to a text file. I have used your code with some of my own. The data I am dealing with is extremely line-length specific and after the macro has run, the text file contains some double quotation marks " at random places, which was never present in my data before. I have tried adding a code line to remove this character at various stages but that does not seem to be working. I am aware that I can manually remove this but would like to resolve it in the VBA code.

Sub Macro3()
Dim wb As Workbook
Dim saveFile As String
Dim WorkRng As Range
On Error Resume Next
Selection.AutoFilter
ActiveSheet.Range("$A$1:$B$10591").AutoFilter Field:=1, Criteria1:= _
"=NSZAP*", Operator:=xlAnd
Range("A1").Select
ActiveCell.Offset(200, 0).Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveCell.Rows("1:10101").EntireRow.Select
Selection.Delete Shift:=xlUp
Range("A1").Select
Selection.AutoFilter
Range(Selection, Selection.End(xlDown)).Select
Set WorkRng = Application.Selection
Set wb = Application.Workbooks.Add
WorkRng.Copy
wb.Worksheets(1).Paste
Selection.Replace What:="""", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
saveFile = Application.GetSaveAsFilename(fileFilter:="Text Files (*.txt), *.txt")
Selection.Replace What:="""", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
wb.SaveAs Filename:=saveFile, FileFormat:=xlText, CreateBackup:=False
Selection.Replace What:="""", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
wb.Close
Application.CutCopyMode = False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
Hi Harish,
For removing a specified character in bulk, you can replace the character with nothing.
Ctrl + H to open the Find and Replace dialog box, type the specified character in the Find what box, and type noting in the replace with box.
This comment was minimized by the moderator on the site
3/2 You might also note that you don't need to specify the wb prefix once you've .Add ed the workbook since it becomes active. Specifying wb might or might not be more efficient but it can be omitted from some commands. Actually I entirely scrapped the variable wb; I just go Workbooks.Add, and use ActiveWorkbook when needed. (As you are suppressing ScreenUpdating it wouldn't be obvious to some that wb is Active. Tip for beginners (and higher): I always, always develop with ScreenUpdating and DisplayAlerts as True, and when done with development, I consider toggling them off for some passage of code.)
This comment was minimized by the moderator on the site
2/2 - vbYesNoCancel msgboxes and Booleans to indicate whether to export all, selection, or a user specified range - a static String for the prior range address - if len(that static)1 then I set WorkRng=activesheet.UsedRange (You can't copy multiple areas with a single copy, though with a little work you could walk the areas and copy them piecemeal.) - Idiotic Microsoft does not save off empty rows at the start and the bottom of the saved range, and does not save off empty columns at the leftmost and the rightmost of the saved range. When I detect that (UsedRange is not row 1, col. 1, or xlLastCell is not completely lower-right) I msgbox to ask user if they want to plug A1 or the lower right cell. - Then I decided to preemptively address the upper left issue by inserting a row and setting A1 to be text like "The following is for range " - I close with activeworkbook.close SaveChanges:=False - Long time habit since I'm an angry proponent of cleaning up (and the world is a sad place thanks to irresponsible programmers who shirk that responsibility when it matters), I set WorkRng = Nothing on the way out :)
This comment was minimized by the moderator on the site
1/2 (since your software limits comment length) I am a serious coder and I want to inform you that the VBA code here is outstanding. It's clean, and not one line too much, or one too few. It's exemplary coding for demonstration of the process. I'll also mention that as I extensively researched solutions for export of selection, you and only one other person suggested dropping the range into a temp new workbook. All other answers were painfully manually, walking through cell by cell. Even Chip's code is much longer and runs slower (but intentionally so, as it is much more flexible - specifiable delimiters, etc.) Just for your amusement, I made some very minor tweaks but otherwise nearly lifted the code word for word because it basically dropped right into a very intricate and specialized application. Some of these tweaks are something I'm sure you do in practice, but they add lines of code (e.g. error checking) so showing them on this webpage would have muddied your display so that the essential elements of processing would have been cumbersome for readers to follow along. Anyway: (see part 2)
This comment was minimized by the moderator on the site
My query is as mentioned below: I have a report to generate everyday. The data what I get on the final row (only one row but more than one columns) I want it to export to another excel sheet which is a summary excel sheet saved separately on my desktop. Eg: Day1 report - final row export to Summary excel sheet row1 Day2 report - final row export to Summary excel sheet row2 Day3 report - final row export to Summary excel sheet row3 and so on.. Export should be done through a click button., which means when I click on export button the data on the sheet I calculated today should go and save on the Summary excel sheet row1, next day a new excel sheet report calculated should go and save on the Summary excel sheet row2 and so on.. Will this be possible to do... If yes please someone help me on this... Thank you in advance...:-)
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations