PDA

View Full Version : Referencing cells in embedded worksheets in Word



werhand
06-09-2009, 02:52 PM
Does anybody know of a VBA solution to be able to reference a cell in one embedded worksheet in a Word document by a different embedded worksheet in the same Word document? For example, Worksheet A has a table with a sum of a column, and later in the document Worksheet B needs that sum to perform further calculations on. I need the document to be self-contained (otherwise I would just use a linked worksheet instead of embedded worksheets).

I have attempted a non-VBA solution by opening two embedded worksheets and creating a reference (creates a cell entry in Worksheet B as "='Worksheet in Filename.doc'!A1"), but the document includes numerous (more than a dozen) embedded worksheets and the generic "worksheet" creates problems when you start referencing more than one worksheet.

Any ideas would be appreciated! If somebody knows a non-VBA solutions, that would be useful as well!

macropod
06-09-2009, 03:47 PM
Hi werhand,

Word's ability to automate and work with embedded worksheets is, shall we say, limited. It's far easier to work with Word tables - especially since all you're after is the sum of a column; in fact, with a Word table, you don't even need vba.

To see how to use Word tables and fields, for this and a wide range of other calculations in Word, check out my Word Field Maths Tutorial, at:
http://www.wopr.com/index.php?showtopic=365442 (mhtml:{2603C627-B617-484B-B3E3-521BCFB808E8}mid://00000014/!x-usc:http://www.wopr.com/index.php?showtopic=365442)
or
http://www.gmayor.com/downloads.htm#Third_party (mhtml:{2603C627-B617-484B-B3E3-521BCFB808E8}mid://00000014/!x-usc:http://www.gmayor.com/downloads.htm#Third_party)

werhand
06-10-2009, 06:24 AM
Thanks for the suggestion!