Solved

Transfer a notepad data into the clipboard

Posted on 2004-04-08
8
564 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 86

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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

726 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