Problem with SendKeys and first Capital letter

W

WCyrek

Hi when usign sendkeys in my vba programs I often run
into ptoblem that the first capital letter that sendkeys
types comes out twice. I suspected many things but my
best guess it's somethign to do with AS YOU TYPE options
that auto correct soem thigns, since mimics user typing.
However I have not been able to find the actual option
responsible for this. Has anyone else had simular
problem? If it has to do with AS YOU TYPE what should I
do so that the program works perfectly in any word no
matter the AS YOU TYPE settigns? If that's not what to
blame, then what is?
 
M

MSizlak

It sounds like you're using Sendkeys to insert words into
a document. If so, selection.typetext "[STRING]" might be
better for you anyway.
Moe
 
W

WCyrek

-----Original Message-----
It sounds like you're using Sendkeys to insert words into
a document. If so, selection.typetext "[STRING]" might be
better for you anyway.
Moe
-----Original Message-----
Hi when usign sendkeys in my vba programs I often run
into ptoblem that the first capital letter that sendkeys
types comes out twice. I suspected many things but my
best guess it's somethign to do with AS YOU TYPE options
that auto correct soem thigns, since mimics user typing.
However I have not been able to find the actual option
responsible for this. Has anyone else had simular
problem? If it has to do with AS YOU TYPE what should I
do so that the program works perfectly in any word no
matter the AS YOU TYPE settigns? If that's not what to
blame, then what is?
.
.
 
W

WCyrek

I used to use ^b with sendkeys so I could switch between
bold and regular text easily. How can I do that with the
Selection.TypeText method?

-----Original Message-----
-----Original Message-----
It sounds like you're using Sendkeys to insert words into
a document. If so, selection.typetext "[STRING]" might be
better for you anyway.
Moe
-----Original Message-----
Hi when usign sendkeys in my vba programs I often run
into ptoblem that the first capital letter that sendkeys
types comes out twice. I suspected many things but my
best guess it's somethign to do with AS YOU TYPE options
that auto correct soem thigns, since mimics user typing.
However I have not been able to find the actual option
responsible for this. Has anyone else had simular
problem? If it has to do with AS YOU TYPE what should I
do so that the program works perfectly in any word no
matter the AS YOU TYPE settigns? If that's not what to
blame, then what is?
.
.
.
 
C

Chad DeMeyer

Dim oRng as Range
Set oRng = Selection.Range
oRng.Text = "[STRING]"
oRng.Bold = True

Regards,
Chad


WCyrek said:
I used to use ^b with sendkeys so I could switch between
bold and regular text easily. How can I do that with the
Selection.TypeText method?

-----Original Message-----
-----Original Message-----
It sounds like you're using Sendkeys to insert words into
a document. If so, selection.typetext "[STRING]" might be
better for you anyway.
Moe
-----Original Message-----
Hi when usign sendkeys in my vba programs I often run
into ptoblem that the first capital letter that sendkeys
types comes out twice. I suspected many things but my
best guess it's somethign to do with AS YOU TYPE options
that auto correct soem thigns, since mimics user typing.
However I have not been able to find the actual option
responsible for this. Has anyone else had simular
problem? If it has to do with AS YOU TYPE what should I
do so that the program works perfectly in any word no
matter the AS YOU TYPE settigns? If that's not what to
blame, then what is?
.

.
.
 
W

WCyrek

The range is a cell in a table and half of the text
should be bold and the other half not? The bold stuff is
a string I get from a textbox in a userform if that makes
it easier
-----Original Message-----
Dim oRng as Range
Set oRng = Selection.Range
oRng.Text = "[STRING]"
oRng.Bold = True

Regards,
Chad


I used to use ^b with sendkeys so I could switch between
bold and regular text easily. How can I do that with the
Selection.TypeText method?

-----Original Message-----

-----Original Message-----
It sounds like you're using Sendkeys to insert words
into
a document. If so, selection.typetext "[STRING]" might
be
better for you anyway.
Moe
-----Original Message-----
Hi when usign sendkeys in my vba programs I often run
into ptoblem that the first capital letter that
sendkeys
types comes out twice. I suspected many things but my
best guess it's somethign to do with AS YOU TYPE
options
that auto correct soem thigns, since mimics user
typing.
However I have not been able to find the actual option
responsible for this. Has anyone else had simular
problem? If it has to do with AS YOU TYPE what
should
I
do so that the program works perfectly in any word no
matter the AS YOU TYPE settigns? If that's not what to
blame, then what is?
.

.

.


.
 
M

MSizlak

What Chad gave you still applies. Just collapse the
selection to the start or end of the table cell
(depending on whether you want your textbox text to be
the first or second "half" of the cell's text), then
execute Chad's code, passing the textbox value into
the "[STRING]" slot as a variable.

Unless I'm mistaken, that logic should work fine.

Moe
-----Original Message-----
The range is a cell in a table and half of the text
should be bold and the other half not? The bold stuff is
a string I get from a textbox in a userform if that makes
it easier
-----Original Message-----
Dim oRng as Range
Set oRng = Selection.Range
oRng.Text = "[STRING]"
oRng.Bold = True

Regards,
Chad


I used to use ^b with sendkeys so I could switch between
bold and regular text easily. How can I do that with the
Selection.TypeText method?


-----Original Message-----

-----Original Message-----
It sounds like you're using Sendkeys to insert words
into
a document. If so, selection.typetext "[STRING]" might
be
better for you anyway.
Moe
-----Original Message-----
Hi when usign sendkeys in my vba programs I often run
into ptoblem that the first capital letter that
sendkeys
types comes out twice. I suspected many things but my
best guess it's somethign to do with AS YOU TYPE
options
that auto correct soem thigns, since mimics user
typing.
However I have not been able to find the actual option
responsible for this. Has anyone else had simular
problem? If it has to do with AS YOU TYPE what should
I
do so that the program works perfectly in any word no
matter the AS YOU TYPE settigns? If that's not
what
.
 
W

WCyrek

Dim oRng as Range
Set oRng = Selection.Range
With oRng
.Text = "First part"
.Collapse Direction:=wdCollapseEnd
.MoveEnd Unit:=wdCharacter, Count:=-1
.Text = "Second part"
.Bold = True
End With

So far so good however I always had a blank line as the
last line of the cell. .TypeEnter would work with that?
If so I still ahev to move one character back after
collapsing so Im not behind the paragraph marker?
-----Original Message-----
What Chad gave you still applies. Just collapse the
selection to the start or end of the table cell
(depending on whether you want your textbox text to be
the first or second "half" of the cell's text), then
execute Chad's code, passing the textbox value into
the "[STRING]" slot as a variable.

Unless I'm mistaken, that logic should work fine.

Moe
-----Original Message-----
The range is a cell in a table and half of the text
should be bold and the other half not? The bold stuff is
a string I get from a textbox in a userform if that makes
it easier
-----Original Message-----
Dim oRng as Range
Set oRng = Selection.Range
oRng.Text = "[STRING]"
oRng.Bold = True

Regards,
Chad


"WCyrek" <[email protected]> wrote
in
message
I used to use ^b with sendkeys so I could switch between
bold and regular text easily. How can I do that with the
Selection.TypeText method?


-----Original Message-----

-----Original Message-----
It sounds like you're using Sendkeys to insert words
into
a document. If so, selection.typetext "[STRING]" might
be
better for you anyway.
Moe
-----Original Message-----
Hi when usign sendkeys in my vba programs I often run
into ptoblem that the first capital letter that
sendkeys
types comes out twice. I suspected many things
but
my
best guess it's somethign to do with AS YOU TYPE
options
that auto correct soem thigns, since mimics user
typing.
However I have not been able to find the actual option
responsible for this. Has anyone else had simular
problem? If it has to do with AS YOU TYPE what should
I
do so that the program works perfectly in any
word
no
matter the AS YOU TYPE settigns? If that's not
what
to
blame, then what is?
.

.

.



.
.
.
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < WCyrek > écrivait :
In this message, < WCyrek > wrote:

|| Dim oRng as Range
|| Set oRng = Selection.Range
|| With oRng
|| .Text = "First part"
|| .Collapse Direction:=wdCollapseEnd
|| .MoveEnd Unit:=wdCharacter, Count:=-1
|| .Text = "Second part"
|| .Bold = True
|| End With
||
|| So far so good however I always had a blank line as the
|| last line of the cell. .TypeEnter would work with that?

You mean that you want to add a ¶ at the end of the cell so as to create a
blank line?
If so, try:
.Text = "Second part" & Chr(13)

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
W

WCyrek

-----Original Message-----
Bonjour,

Dans son message, < WCyrek > écrivait :
In this message, < WCyrek > wrote:

|| Dim oRng as Range
|| Set oRng = Selection.Range
|| With oRng
|| .Text = "First part"
|| .Collapse Direction:=wdCollapseEnd
|| .MoveEnd Unit:=wdCharacter, Count:=-1
|| .Text = "Second part"
|| .Bold = True
|| End With
||
|| So far so good however I always had a blank line as the
|| last line of the cell. .TypeEnter would work with that?

You mean that you want to add a ¶ at the end of the cell so as to create a
blank line?
If so, try:
.Text = "Second part" & Chr(13)

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org



.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top