Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Transfer a notepad data into the clipboard

Posted on 2004-04-08
8
Medium Priority
?
583 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 400 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

715 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