Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default Accessing a Text Box in a Word Document from Excel

How can I copy a string from my exel document to a text box on a form in a
word document?

I can open the word document with the following:

Dim appWD As Word.Application
Set appWD = CreateObject("Word.Application")
appWD.Documents.Open Filename:=strPath & "\Letter.dot"

I just dont know how to refence the text box to then make it equal to the
string.

Thanks for your help in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 212
Default Accessing a Text Box in a Word Document from Excel

In excel first add reference to "Mocrosoft Word xx.x Object Library"
Add following code below the last line of your code and see.

'1. Referring by index number: First find out the inderx number of the text
box. if it is the only Shape in document it will be 1.
' Replace (n) below with the index number.

appWD.ActiveDocument.Shapes(n).TextFrame.TextRange .Text = "Was the reference
to text box success?"
appWD.ActiveDocument.SaveAs ("C:\letter1.doc")
appWD.ActiveDocument.Close
Exit sub

'2: Referring by name: First find out the name of the text box object -
which Typically will be "Text Box n".
'Replace n with the correct number.

appWD.ActiveDocument.Shapes("Text Box n").TextFrame.TextRange.Text = "Was
the reference to text box success?"
appWD.ActiveDocument.SaveAs ("C:\letter1.doc")
appWD.ActiveDocument.Close
Exit sub

Sharad


"Ben" wrote in message
...
How can I copy a string from my exel document to a text box on a form in a
word document?

I can open the word document with the following:

Dim appWD As Word.Application
Set appWD = CreateObject("Word.Application")
appWD.Documents.Open Filename:=strPath & "\Letter.dot"

I just dont know how to refence the text box to then make it equal to the
string.

Thanks for your help in advance.



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
Attach Word document to a text box in Excel Ahmed Habib[_2_] Excel Discussion (Misc queries) 0 July 15th 09 08:23 PM
Attach Word document to a text box in Excel Ahmed Habib[_2_] Excel Discussion (Misc queries) 1 July 15th 09 03:13 PM
Attach Word document to a text box in Excel Ahmed Habib Excel Discussion (Misc queries) 1 July 14th 09 07:58 PM
moving text from a word document to excel gregp22 New Users to Excel 2 March 21st 06 06:18 PM
Accessing Word from Excel pikus Excel Programming 4 January 14th 04 07:41 PM


All times are GMT +1. The time now is 05:08 PM.

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

About Us

"It's about Microsoft Excel"