• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 604
  • Last Modified:

Transfer a notepad data into the clipboard

I need open a text file contents into the clipboard using VB (I can use shell and open the notepad , but then I have to close the file everytime).So the best solution for me is to put the contents in the clipboard and clear the clipboard when needed.


Please note : I'm doing this entire programming on MS Access 2000 and am not sure if this would have any limitations over a full pledge VB.
0
ranga_hari
Asked:
ranga_hari
  • 3
  • 2
  • 2
  • +1
1 Solution
 
jjafferrCommented:
Hi ranga_hari,

Dim MyString
Open "c:\YourReportOutput.txt" For Input As #1    ' Open file for input.
Do While Not EOF(1)    ' Loop until end of file.
    Line Input #1, MyString    ' Read each Line into MyString variable.
    FullText = FullText & MyString     'Put all the Lines read into one String, FullText
Loop
Close #1    ' Close file.


I Hope this helps

jaffer
0
 
ranga_hariAuthor Commented:
Does not help me :( I need the clipboard bit of programming.This does not help the data to be moved into the clipboard.
0
 
jjafferrCommented:
OK another go

use code to open notepad ( I have it somewhere)
sendkeys ^all, true 'select all
sendkeys ^c, true 'Copy
use code to code notepad (this I don't have)

jaffer
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
ranga_hariAuthor Commented:
Thanks dude ...I can use shell and open the notepad .But I dont want to open the application seoperately.I want the notepad content transfered to the clipboard without opening the notepad.exe
0
 
jjafferrCommented:
Check this out to copy to the clipboard
http://www.vbcode.com/asp/showsn.asp?theID=404
0
 
ShauliCommented:
Dim myString As String, myText As String
Open "mypath&filename.txt" For Input As #1 'modify with your file
    Do Until EOF(1)
        Line Input #1, myString
        myText = myText & myString & vbCrLf
    Loop
Close #1
Clipboard.SetText myText, vbCFText 'add to clipboard

S
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Unfortunately Shauli, there is no clipboard object in MS Access.

If you don't want to use the API's, then here is a workaround.  Use this code on a Form that has a TextBox0.  Unfortunately, the TextBox must be visible for this to work.  You can hide it behind something else maybe.

Regards,

Idle_Mind

Private Sub Command2_click()
    Dim fileName As String
    Dim fileContents As String
    fileName = CurrentProject.Path & "\Input.txt"
    If Dir(fileName) <> "" Then
        Open fileName For Binary As #1
        fileContents = Space(LOF(1))
        Get #1, , fileContents
        Close #1
        Text0.SetFocus
        Text0.Text = fileContents
        Text0.SelStart = 0
        Text0.SelLength = Len(Text0.Text)
        DoCmd.RunCommand acCmdCopy
    End If
End Sub
0
 
ShauliCommented:
Oh, MS Access, sorry, my mistake :(
S
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now