Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Excel value onto word userform

Hi
I'm trying to import an excel cell value into a textbox on a word userform.
I've managed(with the help of code found in the forums to open a document
based on a word template and get the word userform to display but
cannot get the cell value to populate the textbox on the word userform.

Example code below(Office 2003)
________________________
Private Sub cmdQuote_Click()
Dim WD As Object
Dim MyDoc As Object

Set WD = CreateObject("Word.Application")

With WD

Set MyDoc = .Documents.Add(Template:= _
"C:\Documents and Settings\Owner\Desktop\Gas Quotation.dot", _
NewTemplate:=False, DocumentType:=0)

MyDoc.Activate

MyDoc.UserForm("txtAdd1").Result = ActiveSheet.Range("C8").Value
'**********

..Visible = True

End With
End Sub
__________________


TIA
--
Al@n


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Excel value onto word userform

I am not the person to ask and this is not the newsgroup for Word programming help.
However, maybe I won't do any damage...

A textbox (Word or Excel) does not have a "Result" property.
Also, you need to specify the Application | Document | Userform | Textbox that
gets the cell value. So it should look something like...

MyDoc.UserForm1.txtAdd1.Value = ThisWorkbook.ActiveSheet.Range("C8").Value
--
Jim Cone
Portland, Oregon USA



"Al@n"
wrote in message
Hi
I'm trying to import an excel cell value into a textbox on a word userform.
I've managed(with the help of code found in the forums to open a document
based on a word template and get the word userform to display but
cannot get the cell value to populate the textbox on the word userform.
Example code below(Office 2003)

Private Sub cmdQuote_Click()
Dim WD As Object
Dim MyDoc As Object

Set WD = CreateObject("Word.Application")
With WD
Set MyDoc = .Documents.Add(Template:= _
"C:\Documents and Settings\Owner\Desktop\Gas Quotation.dot", _
NewTemplate:=False, DocumentType:=0)
MyDoc.Activate
MyDoc.UserForm("txtAdd1").Result = ActiveSheet.Range("C8").Value
'**********
..Visible = True
End With
End Sub

TIA
--
Al@n


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Excel value onto word userform

Jim

Thanks for the reply.

The reason I posted in this newsgroup was because I'm trying to control Word
from Excel with the code below in an Excel Module.
I deliberated as to where I should ask the question but didn't wish to post
in multiple groups.

I have tried your suggestion but to no avail, Word opens, Userform1 displays
but there is still no text from range C8 in txtAdd1.

Regarding my original code, I have a spreadsheet on which a userform, whilst
populating the spreadsheet, can also open and populate a Word userform
using code similar to that below:

MyDoc.FormFields("Text1").Result = UserForm1.TextBox1.Value

That is why I was trying to use "result" instead of "value"

Anyhow, thanks once again for your response and I'll keep trying.

Al@n




"Jim Cone" wrote in message
...
I am not the person to ask and this is not the newsgroup for Word
programming help.
However, maybe I won't do any damage...

A textbox (Word or Excel) does not have a "Result" property.
Also, you need to specify the Application | Document | Userform | Textbox
that
gets the cell value. So it should look something like...

MyDoc.UserForm1.txtAdd1.Value = ThisWorkbook.ActiveSheet.Range("C8").Value
--
Jim Cone
Portland, Oregon USA



"Al@n"
wrote in message
Hi
I'm trying to import an excel cell value into a textbox on a word
userform.
I've managed(with the help of code found in the forums to open a document
based on a word template and get the word userform to display but
cannot get the cell value to populate the textbox on the word userform.
Example code below(Office 2003)

Private Sub cmdQuote_Click()
Dim WD As Object
Dim MyDoc As Object

Set WD = CreateObject("Word.Application")
With WD
Set MyDoc = .Documents.Add(Template:= _
"C:\Documents and Settings\Owner\Desktop\Gas Quotation.dot", _
NewTemplate:=False, DocumentType:=0)
MyDoc.Activate
MyDoc.UserForm("txtAdd1").Result = ActiveSheet.Range("C8").Value
'**********
.Visible = True
End With
End Sub

TIA
--
Al@n




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
Excel and Word crash when I try to add a UserForm interrogativo Excel Programming 4 August 21st 17 03:49 PM
Inserting contents of a Word document into a Userform in Excel [email protected] Excel Programming 0 August 28th 07 05:29 PM
transfer data from word userform to excel Jade Excel Programming 1 January 29th 07 09:15 PM
Open Word Document from Excel Userform Myrna Rodriguez[_3_] Excel Programming 2 January 12th 06 06:47 PM
Filling Userform in Word with Excel cell value. AW Excel Programming 0 April 4th 04 10:15 PM


All times are GMT +1. The time now is 08:23 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"