SendKeys

  • Thread starter Thread starter Arnie
  • Start date Start date
A

Arnie

can anyone help i am using

SendKeys "C:\Documents and Settings\Fred_Bloggs\My
Documents\Folder1\Folder2\AnyThing.txt{Enter}", Wait:=True

however i want anyone to use this so i want to get rid of "Fred_Bloggs"

i tried

SendKeys Thisworkbook.Path & "\Folder2\AnyThing.txt{Enter}", Wait:=True

but its not happy any ideas?

Thanks
Arnie
 
Try this code. It opens a Notepad application using your filename and then
sends the key to the active window.

Sub test()
FName = "C:\Documents and Settings\Fred_Bloggs\" & _
"My Documents\Folder1\Folder2\AnyThing.txt"

MyAppID = Shell("notepad.exe" & FName, 1) ' Run Microsoft Word.
AppActivate MyAppID ' Activate Microsoft

SendKeys "{Enter}", Wait:=True

End Sub
 
Thanks Joel :-)

Joel said:
Try this code. It opens a Notepad application using your filename and then
sends the key to the active window.

Sub test()
FName = "C:\Documents and Settings\Fred_Bloggs\" & _
"My Documents\Folder1\Folder2\AnyThing.txt"

MyAppID = Shell("notepad.exe" & FName, 1) ' Run Microsoft Word.
AppActivate MyAppID ' Activate Microsoft

SendKeys "{Enter}", Wait:=True

End Sub
 
It looks like I'm missing a space in the following instruction

from
MyAppID = Shell("notepad.exe" & FName, 1) ' Run Microsoft Word.
to
MyAppID = Shell("notepad.exe " & FName, 1) ' Run Microsoft Word.


You don't have to open a notepad application if the window is already
opened. You can use the Window name instead of the process ID in the
AppActivate

AppActivate "AnyThing.txt"
 
Back
Top