Solved

Problem with Sendkeys

Posted on 2006-06-24
3
193 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DIR issue 7 54
Macro which automatically sends attachment to Outlook 14 71
SQL VB connection works in one PC and doesn't in another 15 64
VB6 - Scroll Mouse wheel on Picturebox 13 44
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.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 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…

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