ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Paste into opened notepad file (https://www.excelbanter.com/excel-programming/347049-paste-into-opened-notepad-file.html)

oOpsy[_7_]

Paste into opened notepad file
 

May i know how do i continue from my code below in order to allow me to
copy sheet3 cells A1:A42 into the opened file? I am able to call
notepad to open the .xml file but i need to paste the data from excel
into this opened file.Thanks!!

Private Sub CommandButton1_Click()
Shell "C:\Windows\Notepad.exe 'C:\project\fyp1.xml"

End Sub


--
oOpsy
------------------------------------------------------------------------
oOpsy's Profile: http://www.excelforum.com/member.php...o&userid=29132
View this thread: http://www.excelforum.com/showthread...hreadid=489798


oOpsy[_9_]

Paste into opened notepad file
 

any kind soul able to help

--
oOps
-----------------------------------------------------------------------
oOpsy's Profile: http://www.excelforum.com/member.php...fo&userid=2913
View this thread: http://www.excelforum.com/showthread.php?threadid=48979


Charlie

Paste into opened notepad file
 
I don't know how to paste the clipboard contents into another spawned process
as you want. There may be a way to do it, but I would suggest reading about
opening/closing/reading/writing to text files in VB help.

You don't say where you want to paste the cell contents in the file. Below
are two examples. The first one appends the cells to the end of the file.
The second one appends each cell to the end of each line of the text file,
assuming there is one line for each cell.

I did not test these examples, they are simply to give you an idea how to
get started.

' Method 1 - append to end of file

Dim Cell As Range

Open "C:\project\fyp1.xml" For Append As #1

For Each Cell In Sheets("Sheet3").Range("A1:A42")
Print #1, Cell.Text
Next Cell

Close #1

' Method 2 - append to end of each line of file

Dim Rec As String
Dim nRec As Long

Open "C:\project\fyp1.xml" For Input As #1
Open "C:\project\fyp1_NEW.xml" For Output As #2

Do While Not EOF(1)
Line Input #1, Rec
nRec = nRec + 1
Print #1, Rec & Sheets("Sheet3").Cells(nRec, 1).Text
Loop

Close #1
Close #2


"oOpsy" wrote:


any kind soul able to help?


--
oOpsy
------------------------------------------------------------------------
oOpsy's Profile: http://www.excelforum.com/member.php...o&userid=29132
View this thread: http://www.excelforum.com/showthread...hreadid=489798




All times are GMT +1. The time now is 08:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com