Solved

Transfer a notepad data into the clipboard

Posted on 2004-04-08
8
563 Views
Last Modified: 2010-05-02
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
Comment
Question by:ranga_hari
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 27

Expert Comment

by:jjafferr
ID: 10787335
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
 

Author Comment

by:ranga_hari
ID: 10787447
Does not help me :( I need the clipboard bit of programming.This does not help the data to be moved into the clipboard.
0
 
LVL 27

Expert Comment

by:jjafferr
ID: 10787482
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
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.

 

Author Comment

by:ranga_hari
ID: 10787526
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
 
LVL 27

Expert Comment

by:jjafferr
ID: 10787664
Check this out to copy to the clipboard
http://www.vbcode.com/asp/showsn.asp?theID=404
0
 
LVL 19

Expert Comment

by:Shauli
ID: 10788715
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
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 100 total points
ID: 10789351
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
 
LVL 19

Expert Comment

by:Shauli
ID: 10790714
Oh, MS Access, sorry, my mistake :(
S
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question