Results 1 to 4 of 4

Thread: [RESOLVED] Send keys and quotation marks

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    2

    Resolved [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")

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Send keys and quotation marks



    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:
    1. Public Sub Replace34(sFilename As String, sReplaceWith As String)
    2.    
    3.     Dim tmp As String
    4.     Open sFilename For Input As #1
    5.         tmp = Input(LOF(1), 1)
    6.     Close #1
    7.    
    8.     tmp = Replace(tmp, Chr(34), sReplaceWith)
    9.    
    10.     Open sFilename For Output As #1
    11.         Print #1, tmp
    12.     Close #1
    13.    
    14. End Sub

    now to use it.. call it from somewhere...

    VB Code:
    1. 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?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    2

    Re: Send keys and quotation marks

    Mate, This worked like a charm!

    Cheers.

    V

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    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!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width