open a word doc

fqb34r

Board Regular
Joined
Nov 28, 2005
Messages
71
Hi
is there a way i can open a word doc (template) and incert fields from my spread sheet i can do it with an email

i have a spred sheet were i keep customers information on and would like to print a receipts

kevin
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
i thought i would make my self a little more clear

i have a spread sheet were i log request from work collegs

a b c d e f g
1 ref no name date request sent to reply receipt
2
3

now i have a link so i can send a email to the relevent department incerting the ref no name request ect automaticly but would like to print a receipt when i have a relpy in the form of a letter to the person making the request incerting the ref no name ect

i am trying to do in with a word doc but any other ideas would be good
 
Upvote 0
You can set the reference to Word in the VBA screen of your workbook, so use Alt + F11 and then go to Tools Menu and scroll down until you find Microsoft Word XX .Object Library and tick the box and close that box, then select Insert Menu and Module add this code.

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> openWord()<br><SPAN style="color:#00007F">Dim</SPAN> wrdApp <SPAN style="color:#00007F">As</SPAN> word.Application<br><SPAN style="color:#00007F">Set</SPAN> wrdApp = CreateObject("word.application")<br>Range("B5").Copy <SPAN style="color:#007F00">'Adjust to cell ID</SPAN><br><SPAN style="color:#00007F">With</SPAN> wrdApp<br>    .Visible = <SPAN style="color:#00007F">True</SPAN><br>    .documents.Open "Enter path to document and include.Doc"<br>    <SPAN style="color:#007F00">'If you are using a bookmark refer to the bookmark</SPAN><br>    <SPAN style="color:#007F00">'What do you want to do next</SPAN><br>    <SPAN style="color:#007F00">'Record a paste command</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0
when i go the the tools menu there is no Microsoft Word XX option and if it is somthing i have to add on i wont be able to use it at work

kevin
 
Upvote 0
Did you see Microsoft Word at all in the Visual Basic screen, in the Tools Menu and Under References? the XX means it should show a number without knowing which version I can't tell you what number to look for...

What version are you using...
 
Upvote 0
thanks i have done that

i would like now to be able to open a template and incert the ref no name date request and reply in so that can be sent to the aplicant a record of his request

kevin
 
Upvote 0
Ok Kevin, in the code I showed you this

.Documents.Open
Change that to

Documents.Add Template:= _
"C:\Program Files\microsoft office\Templates\1033\FAX\EquityFax.Dotx", _
NewTemplate:=False, DocumentType:=0

You will have to change the path to your template.

Now the extra questions that are required.

Do you have Bookmarks in the Template in the places where you want the Range information to go?

If not can you create them in your Template, this will make it easier to take the cell information and place it into the correct point in the Template.

Have you ever Recorded a Macro in Word to give you the code for BookMark and Finding the BookMark and then adding text to it?
 
Upvote 0
Trevor

no i have never used templates before or macros in word give me a little time to look into them any thing i should be looking for


kevin
 
Upvote 0
Ok Kevin,

Open Word and then select to Record a MACRO, give the macro a Name, something Like mcrDocument. Then look to open the document you want to use. Thats a start point. Perhaps then select a position in that document where you want to add some text, then repeat this until you have completed the task. You then have the code, and if you copy it here it will be easier to adjust.

Recording Macros in Word is the same as Excel, what every you do is recorded and the code is available for you to look at and adjust if necessary to run your Sub routines.
 
Upvote 0
Trevor

thank you for you help but its all a little complicated for me i have exported data to a word doc by copy and past special this is in my comfort zone is there any way i could make this work

i found the data entry form and noticed that you can scroll through all you data i was wondering if i can make one cell at the top of a colum scroll through all the other cells below so that i can view any data from any row in that coloum in the first cell then link that to the word doc

proberly unworkable but you never know

kevin
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,729
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top