PDA

View Full Version : excel to work passing data dynamically with bookmarks in word



chandrasekha
05-10-2010, 06:36 AM
BODY { MARGIN: 8px } .LW-yrriRe { FONT: x-small arial } HI All,

How are you doing.I have requirement to carry values from Excel to Word not copy & paste but carry individual values and place it Word in desired location. I am able to do copy and paste the values from excel to word but not to the desire place

I have created .DOT file and bookmark as well in template file and excuted script from excel it's not working. I have attached the files. I highly apprecite gurus help. I see light at the end of the tunnel. Thanks to you all

Thanks in advance

Cheers
Sekhar

lynnnow
05-10-2010, 06:38 AM
Sekhar, why don't you consider using mail merge?

Lincoln

chandrasekha
05-10-2010, 06:44 AM
Thanks for the lightning reply. Actually I am new to VBA, I have seen some posting I have followed it nothing beyond then that..All my application demands is dyanmic insert into Word from Excel where data will be place in Word in desire location

I appreciate if you have any example from Excel to Word. It would be life saver.Thanks in advance

cheers
sekhar

dragon
05-11-2010, 05:51 AM
Sekhar, have a look at Ken Puls' Knowledge Base article on Pushing Excel Named Range Values To Bookmarks in Word...

http://www.vbaexpress.com/kb/getarticle.php?kb_id=381

chandrasekha
05-12-2010, 06:16 AM
HI Dragon, Thanks a billion. I was working the code and there is error called "Error: 5151 There is a problem"..i was trying to work the error but with failed attempt.appreciate your help
thanks once again
cheers

lynnnow
05-12-2010, 06:44 AM
Chandrashekar,

Please answer these questions:

1. Did you create ranges with names in Excel?
2. Did you use the named ranges from Excel for bookmarks created in Word?
3. Did you edit the Word template name to suit your preference?

These answers are necessary to understand where the fault is. Since the KB code is a working example, you may not have followed it to the T and hence the error.

Lincoln

dragon
05-13-2010, 03:59 AM
In addition to lynnow's questions, what version of Excel are you using?

chandrasekha
05-14-2010, 04:19 AM
hi,

Thanks for the response.I have changed the code here and there it's working but I am unable to transfer the code to only sheet1 but i would to fetch the data from sheet2 and sheet3 and so on

- I am using Office 2007
- (1)I am new to VBA not sure I may not be giving correct answer. all my ranges were given in code only I guess
-(2)I have created bookmarks in excel
-(3) I am not sure how to to edit template(.dot)file when ever I edit the template it doesn't allow to save me

Thanks in advance
Sekhar

dragon
05-17-2010, 01:45 AM
I only have Office 2003. However, I think the issue is that you have not created any named ranges. You seem to be referencing the actual range addresses in Excel instead.

Create the named ranges (by clicking on Insert, Name, Define whilst in Excel). Once the ranges are defined, VBA should be able to use them regardless of which sheet they are on.

3. Not sure what the problem is. You should be able to save the .dot file by doing File Save As, and choosing the Save As Type as Document Template (*.dot)