ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Lookup value (https://www.excelbanter.com/excel-programming/409800-lookup-value.html)

Mark

Lookup value
 
I am using Excel 2003. I have a worksheet with names and email addresses.
In this worksheet there are some people with the same name, so I need to be
able to do some sort of lookup on a name which produces all the possibilities
lets say name, identity number, email address which are selectable from a
list in a userform.

Ideally I need to be able to transfer the result from Excel into Word

Is this possible, if so, can someone assist me with some code, please?



ryguy7272

Lookup value
 
See these links for a wealth of information:
http://word.mvps.org/FAQs/InterDev/XLToWordWithDAO.htm

http://word.mvps.org/faqs/interdev/c...wordfromxl.htm

http://word.mvps.org/FAQs/InterDev/C...XLFromWord.htm

Finally, and this is my personal favorite:

Add DocVariables to your Word document, wherever you want the Excel data to
go. For instance in Word click Insert Field DocVariable New Name (I
used First_Name in my example) OK. You will see a space reserved for the
variable. Tap Alt+F9 to display or hide the DocVariable. There are many,
many other methods, using bookmarks, etc. I think the DocVariable method is
the best for countless reasons (too many to go into here; try it you will see
the benefits of using this method).


Sub ControlWordFromXL()

Dim objWord As New Word.Application
Dim doc As Word.Document
Dim bkmk As Word.Bookmark
sWdFileName = Application.GetOpenFilename(, , , , False)
Set doc = objWord.Documents.Open(sWdFileName)
On Error Resume Next

Sheets("Sheet1").Activate
objWord.ActiveDocument.Variables("First_Name").Val ue =
Range("First_Name").Value
objWord.ActiveDocument.Variables("Last_Name").Valu e =
Range("Last_Name").Value
€˜etc€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦.
objWord.ActiveDocument.Fields.Update

On Error Resume Next
objWord.Visible = True

End Sub


Regards,
Ryan--


Regards,
Ryan---
--
RyGuy


"Mark" wrote:

I am using Excel 2003. I have a worksheet with names and email addresses.
In this worksheet there are some people with the same name, so I need to be
able to do some sort of lookup on a name which produces all the possibilities
lets say name, identity number, email address which are selectable from a
list in a userform.

Ideally I need to be able to transfer the result from Excel into Word

Is this possible, if so, can someone assist me with some code, please?




All times are GMT +1. The time now is 09:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com