Barkered
Barkered

Reputation: 67

HTA - How to trigger the find dialog at the click of a button?

If I manually input Ctrl F, this triggers the box, so I'm hoping it's achievable via a button.

The below is the vbscript code I've tried using, similar to an excel VBA sub I've used in the past but it doesn't work.

Sub SubSearch

Set IE = CreateObject("InternetExplorer.Application")
IE.Dialogs(IEDialogFind).Show

End Sub

I've also tried using sendkeys "^F" and this doesn't work either.

Upvotes: 2

Views: 336

Answers (1)

Bond
Bond

Reputation: 16321

SendKeys should work. Here's a simple HTA that uses SendKeys to display the Find dialog box:

<html>
<head>
    <title>HTA Test</title>
    <HTA:APPLICATION>
</head>

<body>
<button onclick="ShowFind()">Click me</button>
</body>

<script language="VBScript">
    Sub ShowFind()
        CreateObject("WScript.Shell").SendKeys "^f"
    End Sub
</script>
</html>

Upvotes: 2

Related Questions