Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 143
Default Accessing Word Constants from Excel

I needed an Excel macro that would let the user enter information about a
client into a worksheet, then, with the click of a button, open a Word
document that I had built that contained placeholders for the actual
information. All the information from the worksheet needed to be inserted
into the Word document and then the document needed to be printed.

I recorded macros in Word for the replace and print functions. I copied
those to the Excel macros and everything worked fined until it ran into
this:

wdPrintAllPages

which is a Word constant and apparently, there wasn't way to access the
Word constants from an Excel macro.

Is that right? If not, how do I change "wdPrintAllPages" so that it will
return that value in Excel.

I was able to find the value of those in VBE for Word and simply hard coded
them into my macros, but I was wondering if there were a more elegant way to
do this.


Thanks for any suggestions.

Ken Loomis


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Accessing Word Constants from Excel

I have seen lots of code that uses latebinding mimic these values:

Const wdPrintAllPages as long = 0

so that the code is more self documenting.

Ken Loomis wrote:

I needed an Excel macro that would let the user enter information about a
client into a worksheet, then, with the click of a button, open a Word
document that I had built that contained placeholders for the actual
information. All the information from the worksheet needed to be inserted
into the Word document and then the document needed to be printed.

I recorded macros in Word for the replace and print functions. I copied
those to the Excel macros and everything worked fined until it ran into
this:

wdPrintAllPages

which is a Word constant and apparently, there wasn't way to access the
Word constants from an Excel macro.

Is that right? If not, how do I change "wdPrintAllPages" so that it will
return that value in Excel.

I was able to find the value of those in VBE for Word and simply hard coded
them into my macros, but I was wondering if there were a more elegant way to
do this.

Thanks for any suggestions.

Ken Loomis


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Accessing Word Constants from Excel

Hi Ken,

There are a few ways to do this. One is the method you used - replacing the
constants with their literal values. Another is to set a reference to the
Word object library via Tools | References. Once Excel has the object
library reference, it will "know" the values of the Word constants.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Ken Loomis wrote:
I needed an Excel macro that would let the user enter information
about a client into a worksheet, then, with the click of a button,
open a Word document that I had built that contained placeholders for
the actual information. All the information from the worksheet needed
to be inserted into the Word document and then the document needed to
be printed.
I recorded macros in Word for the replace and print functions. I
copied those to the Excel macros and everything worked fined until it
ran into this:

wdPrintAllPages

which is a Word constant and apparently, there wasn't way to access
the Word constants from an Excel macro.

Is that right? If not, how do I change "wdPrintAllPages" so that it
will return that value in Excel.

I was able to find the value of those in VBE for Word and simply hard
coded them into my macros, but I was wondering if there were a more
elegant way to do this.


Thanks for any suggestions.

Ken Loomis


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 143
Default Accessing Word Constants from Excel

Thanks, Dave. That worked well.


"Dave Peterson" wrote in message
...
I have seen lots of code that uses latebinding mimic these values:

Const wdPrintAllPages as long = 0

so that the code is more self documenting.

Ken Loomis wrote:

I needed an Excel macro that would let the user enter information about a
client into a worksheet, then, with the click of a button, open a Word
document that I had built that contained placeholders for the actual
information. All the information from the worksheet needed to be inserted
into the Word document and then the document needed to be printed.

I recorded macros in Word for the replace and print functions. I copied
those to the Excel macros and everything worked fined until it ran into
this:

wdPrintAllPages

which is a Word constant and apparently, there wasn't way to access the
Word constants from an Excel macro.

Is that right? If not, how do I change "wdPrintAllPages" so that it will
return that value in Excel.

I was able to find the value of those in VBE for Word and simply hard
coded
them into my macros, but I was wondering if there were a more elegant way
to
do this.

Thanks for any suggestions.

Ken Loomis


--

Dave Peterson



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 143
Default Accessing Word Constants from Excel

Thanks for the help, Jake.

"Jake Marx" wrote in message
...
Hi Ken,

There are a few ways to do this. One is the method you used - replacing
the constants with their literal values. Another is to set a reference to
the Word object library via Tools | References. Once Excel has the object
library reference, it will "know" the values of the Word constants.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Ken Loomis wrote:
I needed an Excel macro that would let the user enter information
about a client into a worksheet, then, with the click of a button,
open a Word document that I had built that contained placeholders for
the actual information. All the information from the worksheet needed
to be inserted into the Word document and then the document needed to
be printed.
I recorded macros in Word for the replace and print functions. I
copied those to the Excel macros and everything worked fined until it
ran into this:

wdPrintAllPages

which is a Word constant and apparently, there wasn't way to access
the Word constants from an Excel macro.

Is that right? If not, how do I change "wdPrintAllPages" so that it
will return that value in Excel.

I was able to find the value of those in VBE for Word and simply hard
coded them into my macros, but I was wondering if there were a more
elegant way to do this.


Thanks for any suggestions.

Ken Loomis




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Constants in Excel Sharon Excel Discussion (Misc queries) 0 July 24th 08 02:38 PM
vba constants for excel diver Excel Discussion (Misc queries) 2 August 25th 05 07:51 PM
Accessing Word constants in Excel Ken Loomis Excel Programming 2 October 25th 04 10:57 PM
accessing constants like msoBarTypeMenuBar Carlos[_4_] Excel Programming 0 June 30th 04 10:58 PM
Accessing Word from Excel pikus Excel Programming 4 January 14th 04 07:41 PM


All times are GMT +1. The time now is 07:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"