Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-16-2021, 12:06 AM
SMehta SMehta is offline Notepad to Word : Pasting Specific text ie between any two blank line from notepad to word Windows 10 Notepad to Word : Pasting Specific text ie between any two blank line from notepad to word Office 2013
Novice
Notepad to Word : Pasting Specific text ie between any two blank line from notepad to word
 
Join Date: Jan 2021
Posts: 29
SMehta is on a distinguished road
Default Notepad to Word : Pasting Specific text ie between any two blank line from notepad to word

Hi
As this is my first post in this forum kindly excuse me for the mistakes while posting a question

There are many VBA forums where coding to count lines of text file and return/get Line number positions but was unable to find any coding for counting Nof of blank lines and its position

I would like to know the Empty Line numbers of text file so that whatever data is there in text file between 2 or more blank line can paste in to word
For eg if i know there are lines with data from Line 4 to 10 therefore Blank Lines in this file would be Line 3 and Line 11.

before the below input Any ideas how can i get List of Blank Line nos
Input shall be from userform textboxes From_Blank Line.Text To_BlankLine.Text
E.G so if i put value 3 in From_Blank Line.Text and 11 in To_BlankLine.Text the lines from text file from 4 to 10 could be pasted

Although it is Easy to Open Notepad and word together and paste the content. But i was searching for a code which will help me achieve to what i desried


1. Mehtod
Code:
Sub NotePad_to_word()
Dim sourceFile As Object
Dim myFilePath As String
Dim myFileText As String
Dim line As String

Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim wrdSelection


myFilePath = "C:\Text-To-MsWord\Sample.txt"

    Set sourceFile = fso.OpenTextFile(myFilePath, ForReading)
    While Not sourceFile.AtEndOfStream 
        line = sourceFile.ReadLine

'''''How to get position of all Blank line nos
    Wend
    sourceFile.Close 

Set wrdApp = CreateObject("Word.Application")
    wrdApp.Visible = True
    Set wrdDoc = wrdApp.Documents.Add

Set wrdSelection = wrdApp.Selection
    wrdSelection.TypeText      '''''  DataAfterFrom in this Eg from Line 4 to Line 10

wrdDoc.Close
    wrdApp.Quit
End sub
Your efforts in guiding me will be appreciated
Thanks
SMehta


thread 1 : Post 1
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help to get data from notepad to word ganesang Word VBA 2 08-11-2019 10:21 PM
Word does not stop at the set tab, but it keeps forever on the same line like it would in Notepad. danvina@gmail.com Word 2 01-16-2019 02:33 PM
Notepad to Word : Pasting Specific text ie between any two blank line from notepad to word Microsoft notepad over word for saving important text files Noclip1 Word 1 10-25-2017 10:55 PM
Notepad to Word : Pasting Specific text ie between any two blank line from notepad to word Copy text with tab at start of line and paste to Notepad JohnTurnbull Word 5 08-27-2017 11:17 PM
Notepad to Word : Pasting Specific text ie between any two blank line from notepad to word Sr. Citizen Question, Please: WORD Shows Blank, But Notepad Shows "Gibberish" ? Robert11 Word 3 08-12-2013 12:35 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:37 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft