Programming the VBE Find/Replace dialog?

D

Doug Glancy

In programming the VBE, is there any way to show it's Find/Replace dialog.
E.g., in programming Excel I could code:

Application.Dialogs(xlDialogFormulaReplace).Show

and get the Find/Replace for Excel. Any way to program the VBE one?

Thanks,

Doug
 
J

Jim Cone

Doug,
This seems to work, however, I have done very little programming dealing
with the VBE.
'--
Sub Experiment()
Dim cmdBar As CommandBar
Set cmdBar = Application.VBE.CommandBars("Menu Bar")
cmdBar.Controls("Edit").Controls("Find...").Execute
Set cmdBar = Nothing
End Sub
'--

You might also want to experiment with code that Chip Pearson posted
in the Misc group today under "Code to Find Code"...
Sub AAA()
Dim FindWhat As String
Dim StartLine As Long
Dim EndLine As Long
Dim StartCol As Long
Dim EndCol As Long
Dim Found As Boolean

With Application.VBE
If .ActiveCodePane Is Nothing Then
MsgBox "No Code Pane Active"
Exit Sub
End If
With .ActiveCodePane
FindWhat = "findme"
StartLine = 0
EndLine = .CodeModule.CountOfLines
StartCol = 0
EndCol = 0
Found = .CodeModule.Find( _
target:=FindWhat, _
StartLine:=StartLine, _
startcolumn:=StartCol, _
EndLine:=EndLine, _
endcolumn:=EndCol, _
wholeword:=False, _
MatchCase:=False, _
PatternSearch:=False)
If Found = True Then
.SetSelection StartLine, StartCol, EndLine, EndCol
Else
MsgBox "Not Found"
End If
End With
End With
End Sub
'----------
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Doug Glancy"
wrote in message
In programming the VBE, is there any way to show it's Find/Replace dialog.
E.g., in programming Excel I could code:
Application.Dialogs(xlDialogFormulaReplace).Show
and get the Find/Replace for Excel. Any way to program the VBE one?
Thanks,
Doug
 
G

Greg Wilson

With Application.VBE.CommandBars("Standard")
.FindControl(ID:=141).Execute
End With

Going from there, if you wish to mainipulate its controls, you could either
use SendKeys or the FindWindowEx API. I have noted that the dialog's
individual controls are Windows common controls. Two are "ComboBox" type and
the others (including checkboxes) are the "Button" type which you can access
with FindWindowEx. Unless this is an important project, SendKeys would be a
lot easier. FindWindowEx is likely to be a lot more reliable but more work to
set up.

Greg
 
D

Doug Glancy

Jim and Greg,

Thanks. I am already working with some code of Chip's for finding code. At
some point I thought it would be great to bring up the Find/Replace dialog,
and fill in the args the way I could with the Excel dialog. Since it
doesn't look like I can do that without fiddling as Greg described, I'll
probably just stick with code like Chip's all the way.

Thanks,

Doug
 

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