Export cell data to text from a specific line

rabatini

New Member
Joined
Oct 31, 2021
Messages
2
Office Version
  1. 2021
Platform
  1. Windows
Hi guys!

I am trying to export a excel data to a text file, but i wanted from a specific line.

example:

this is my text file.

Table Start: 0
Table End: 0
Text Start: 19058
Text End: 193E7
XOffset: 0

Table Type: 0
Text Type: 0
Custom PT: T0 T1

PT Line Command:
-----------------
É muito difícil até aqui esta noite...__Vamos embora de volta à terra Phil,_Meteorologista__Vamos voltar para a Jill no estúdio ...____Naquela nota sombria, e em uma noite chuvosa e tempestuosa.____são definitivamente relacionados com gangues.____O Comissário James confirmou que esses crimes__assassinatos de mutilação no lado sul da cidade.___...Para qualquer informação sobre a recente despeção de___Formalmente oferecendo uma recompensa...__transmissão, o departamento de polícia emitiu uma declaração____Incidentalmente, e repetir o que foi dito anteriormente em nossa____atormentando o lado sul ultimamente._deve ter menos atividade de gangue que está___Ainda com esta chuva mantendo as ruas claras lá____Sim senhor, é uma estação chuvosa.__Tempo úmido, e a má notícia é que há mais a seguir.____a duas semanas seguidas de chuva,__É outra noite chuvosa e chuvosa na grande cidade pessoal.__[ENDBLOCK]

i just want to insert the new text overwrite bold text, its line 13.

my code, erase all text and insert the new text, if i try to append, its print below the text.

in resume, i want export cell data to a specific line inside my text file.

code that i am using.


VBA Code:
Private Sub menu_Click()

    Dim txtNome As String
    Dim txtLinha As String
    Dim nSeq As Long
    Dim rg As Range
    Dim rgRow As Range
    Dim rgCell As Range
    
    'Verifica se os campos Caminho e Nome Arquivo estão em Branco
    If txtCaminho = "" Or txtNomeArquivo = "" Then
        
        MsgBox "Caminho ou Nome do Arquivo em Branco !!"
    
    Else
    
        txtNome = txtCaminho & "\" & txtNomeArquivo & ".txt"
        
        Set rg = Range("B1")
    
        'Obter um número sequencial não utilizado para sequência de abertura de arquivos
        nSeq = FreeFile
    
        'Criar novo arquivo ou sobrescrever arquivo antigo
        Open txtNome For Output As #nSeq
    
        'Loop para percorrer as linhas do intervalo rg
        For Each rgRow In rg.Rows
        
            'Inserir o código de início de uma linha de tabela
            txtLinha = vbLf
        
            'Loop para percorrer as células da linha
            For Each rgCell In rgRow.Cells
                'Concatenar a string para definir uma célula da tabela
                txtLinha = txtLinha & rgCell & vbLf
                
                'Concatenar a string para fechar uma célula da tabela
                txtLinha = txtLinha & " " '"</td>" & vbLf
            Next rgCell
        
            'Concatenar a string para fechar a linha da tabela
            txtLinha = txtLinha '& "</tr>"
            
            'Inserir o código gerado no arquivo txt
            Print #nSeq,
            Print #nSeq, txtLinha
            
        Next rgRow
    
        'Inserir as duas linhas finais do código da tabela
        Print #nSeq,
        Print #nSeq,
        
        'Fechar o arquivo txt
        Close #nSeq
        
        MsgBox "Arquivo criado com sucesso - RIP ROMHACK !!!"
        
    End If
    

End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Insert data from excel to text file, from 13 line of text file to the end.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,607
Members
449,090
Latest member
vivek chauhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top