
customize right-click context menu in Word
Hi Denise,
Quote:
> Do you know if such a macro already exists ?
> Do you think I can do this using
VBA ?
I don't know if one exists, but I am certain you could
develop this yourself. For me, the main question would be:
What's going to be the most efficient way to deal with the
data source?
I suspect using ADO (rather than automating Excel) to the
spreadsheet data would be fastest. Here's a bit of sample
code, to get you started. There's no error handling, or
what should happen if the term can't be found. You'd need
to set a REFERENCE to a (any) "Microsoft ActiveX Data
objects" library in the Visual Basic editor (via the Tools
menu) so that you can use the ADO objects the code
contains.
Sub GetTermEng()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim szSQL As String
Set conn = New ADODB.Connection
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=J:\Testfiles\Terms.xls;" & _
"Extended Properties=""Excel 8.0;HDR=Yes"""
Set rs = New ADODB.Recordset
szSQL = _
"SELECT GermTerm FROM [Sheet1$] WHERE EnglTerm='" _
& Selection.Text & "'"
rs.Open szSQL, conn
Selection.Text = rs.Fields(0).Value
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
End Sub
Cindy Meister
INTER-Solutions, Switzerland
http://www.*-*-*.com/
http://www.*-*-*.com/
http://www.*-*-*.com/
This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:-)