Solved

Problem with Sendkeys

Posted on 2006-06-24
3
176 Views
Last Modified: 2011-10-03
I have a text box with multiline set to true.
I put multiple lines of text in it

For example:
In Form2.Text1 I have:
Line1
Line2
Line3

Then:


Then I set focus to another text box on a different form and use sendkeys like this:
Form1.Text1.SetFocus
SendKeys Chr(34) & Me.Text1.Text & Chr(34)
"Line1

Line2

Line3"

It's inserting and extra return between each line.
Any body know how I can solve this problem.
I know Sendkeys isn't the best thing to use, but  it does fit with my situation


Thanks!
Cheers!
ahammar

0
Comment
Question by:ahammar
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
iHadi earned 500 total points
ID: 16977915
Hi ahammar
Try the following code:


Dim tmpStr As String
tmpStr = Replace(Text1.Text, vbCrLf, Chr(13))

Text2.SetFocus
SendKeys tmpStr
0
 
LVL 23

Author Comment

by:ahammar
ID: 16978061
Hi iHadi,

Thank you!!  It works great!
The points are all yours

Cheers!
ahammar
0
 
LVL 13

Expert Comment

by:iHadi
ID: 16978107
You're welcome
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

706 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

18 Experts available now in Live!

Get 1:1 Help Now