MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old May 22nd, 2002, 03:46 PM   #1
brettvba
MrExcel MVP
 
Join Date: Feb 2002
Location: Christchurch New Zealand
Posts: 1,030
Default

I know absolutly nothing about word can someone help me I have a workbook with some address fields in it.

What I want to do is create a macro that opens up a new letter in word and puts in the address fields selected in excel.

Any Ideas?
brettvba is offline   Reply With Quote
Old May 22nd, 2002, 03:57 PM   #2
sen_edp
Board Regular
 
sen_edp's Avatar
 
Join Date: Mar 2002
Location: Hellas
Posts: 553
Default

Hello Bretvba

I know that word has that option , under tools,mail merge , where you can setup
this communication with excel.


__________________
Best Regards
Andreas
sen_edp is offline   Reply With Quote
Old May 22nd, 2002, 04:27 PM   #3
brettvba
MrExcel MVP
 
Join Date: Feb 2002
Location: Christchurch New Zealand
Posts: 1,030
Default

yeah,

What I really want is just a copy and paste function to put the address in the right spot.

Im using forms and when a user clicks the details they want, I want to open a new document and put in the relevant data in the form of a letter

Any Ideas??
brettvba is offline   Reply With Quote
Old May 22nd, 2002, 04:57 PM   #4
NateO
Legend
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
Default

You could just copy and paste for a one time process. But a macro could look like the following:


Sub WordUp()
Dim WdObj As Object, fname As String
fname = Sheets(2).[a1].Value
Set WdObj = CreateObject("Word.Application")
WdObj.Visible = False
Sheets(1).UsedRange.Copy 'Your Copy Range
WdObj.documents.Add
WdObj.Selection.Paste
Application.CutCopyMode = False
If fname <> "" Then 'make sure fname is not blank
With WdObj
.ChangeFileOpenDirectory "c:temp" 'save Dir
.ActiveDocument.SaveAs Filename:=fname & ".doc"
End With
Else:
MsgBox ("File not saved, naming range was botched, guess again.")
End If
With WdObj
.ActiveDocument.Close
.Quit
End With
Set WdObj = Nothing
End Sub


_________________
Cheers, NateO

[ This Message was edited by: NateO on 2002-05-22 19:17 ]
NateO is offline   Reply With Quote
Old May 22nd, 2002, 05:03 PM   #5
brettvba
MrExcel MVP
 
Join Date: Feb 2002
Location: Christchurch New Zealand
Posts: 1,030
Default

Thanks Nate

I think I can work that to fit my needs

Cheers
brettvba is offline   Reply With Quote
Old May 22nd, 2002, 07:28 PM   #6
brettvba
MrExcel MVP
 
Join Date: Feb 2002
Location: Christchurch New Zealand
Posts: 1,030
Default

sorry i cannot get what I want to work.

What I am trying to achieve is when the macro is run the different fields get transfered from excel into a word document.

I am not sure what I would need to complete this any more Ideas??

brettvba is offline   Reply With Quote
Old May 22nd, 2002, 07:36 PM   #7
NateO
Legend
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
Default

When you say it doesn't work, what do you mean? E.g., errors, nothing, wrong range, etc.....

_________________
Cheers, NateO

[ This Message was edited by: NateO on 2002-05-22 18:37 ]
NateO is offline   Reply With Quote
Old May 22nd, 2002, 07:41 PM   #8
brettvba
MrExcel MVP
 
Join Date: Feb 2002
Location: Christchurch New Zealand
Posts: 1,030
Default

hi Nate

could not get the code to work its also kinda not what Im hoping to do what Ive got is a form with address's on it when the user clicks an address and clicks the create letter button I want it to
Put the required fields in the letter,
I can get the information in variables
but I want to insert the information into word so the user can then create a letter hopefully without copy and paste.

Can you reference lines and columns in word?

Hope thats clear enough can you help?
brettvba is offline   Reply With Quote
Old May 22nd, 2002, 07:43 PM   #9
Mark O'Brien
MrExcel MVP
 
Mark O'Brien's Avatar
 
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
Default

I love the subroutine name there, Cameo.

"Yo, pretty ladies around the world..."

(I've just turned into AudioJoe"
__________________
Mark O'Brien

Columbus Ohio Celtic Supporters Club
Mark O'Brien is offline   Reply With Quote
Old May 22nd, 2002, 08:02 PM   #10
Nimrod
MrExcel MVP
 
Join Date: Apr 2002
Location: Vancouver BC , Canada
Posts: 6,259
Default

Hi Bret.
There Probably is a better way of doing this but it worked for me ....
I was able to select a name in excel and have a form letter open in word with the appropriate information in it ... is that what you want ? If soooo then this is how I did it ....

1) created a extra sheet (you may be able to hide it ) in my xls workbook
2) Put the appropiate headers on the blank xls sheet I.e. name address etc , and added one line of persons information
2)I then wrote a macro to copy the selected row to the "spare" spreadsheet. AND then Open a Word Document called MyFormLetter.

HOW TO CONFIGURE myFormLetter PRIOR to running macro.
1) Open up Word and Open Mail Merge
2) Use Mail Merge wizard to point to the spreadsheet that is blank except for header and 1 line of information.
3) Create you formletter with the one line of information from xls sheet.
4) Save file with 1 line of info showing

DONE:
Now to use, click on the source Spreadsheet which will A) copy the one row of info to the Row One of the sheet that Mail Merge uses for dataBase. B) Opens the Mail Merge document call MyFormLetter with the appropriate information in place.
Nimrod is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 06:36 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes