How to use VLookup in Word VBA? -
i trying prompt user input, lookup info excel report. , populate word document, not sure error is. tried base of operations code this question , this question.
it giving me run-time error '438' object doesn't back upwards property or method. know way utilize method, please point me right direction? give thanks you!
sub populateform() dim objexcel new excel.application dim exwb excel.workbook dim cin_number string dim result string ' prompt user input cin_number = inputbox("please come in cin#", "input") ' open cover sheet letter set exwb = objexcel.workbooks.open("u:\hra cover sheet data.xls") ' perform vlookup... result = objexcel.worksheetfunction.vlookup(cin_number, _ exwb.range("a:f"), 5, false) ' testing output msgbox result exwb.close set exwb = nil end sub i using word 2003, , window xp.
you trying take range of exwb workbook, not worksheet. try
result = objexcel.worksheetfunction.vlookup(cin_number, _ exwb.activesheet.range("a:f"), 5, false) vba ms-word word-vba word-2003
No comments:
Post a Comment