Solved

Transfer a notepad data into the clipboard

Posted on 2004-04-08
8
561 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:ranga_hari
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 27

Expert Comment

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

Expert Comment

by:Shauli
Comment Utility
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
Comment Utility
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
Comment Utility
Oh, MS Access, sorry, my mistake :(
S
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now