[RESOLVED] Send keys and quotation marks
Hi,
I am trying to "find and replace all " double quotes in a text
file(notepad) from Excel. I have used the shell command to open file in notepad but the sendkeys ^H does not seem to open the "find and replace " splash. Below was my last effort of code. I'll appreciate any insights.
Thanks
V
SendKeys ("^H")
objShell.AppActivate "Replace"
Application.Wait (Now + TimeValue("0:00:07"))
SendKeys ("+2")
Application.Wait (Now + TimeValue("0:00:07"))
SendKeys ("%A")
SendKeys ("^S")
Re: Send keys and quotation marks
http://www.vbforums.com/
Using Sendkeys is a very unreliable way to do it.
Great thing is, Excel lets you use VBA! (AS u know)
so, that being said u can do this quickly and reliably:
put this code in a module:
VB Code:
Public Sub Replace34(sFilename As String, sReplaceWith As String)
Dim tmp As String
Open sFilename For Input As #1
tmp = Input(LOF(1), 1)
Close #1
tmp = Replace(tmp, Chr(34), sReplaceWith)
Open sFilename For Output As #1
Print #1, tmp
Close #1
End Sub
now to use it.. call it from somewhere...
VB Code:
Replace34 "C:\path\to\file.txt", "X"
where "X" is what u want to replace the double quotes with
just do "" if u want to remove them
understand?
Re: Send keys and quotation marks
Mate, This worked like a charm!
Cheers.
V
Re: Send keys and quotation marks
If this is resolved.. please go to the thread tools > mark thread resolved
so evenryone knows u have your answer!
thanks! glad to help!