Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default transfer data from word userform to excel

Hello everyone,

Does anyone know the proper method to transfer data directly from a
word userform to an excel spreadsheet.


I have the code below but am having no success...any feedback to
point
me in the right direction as to what I'm doing wrong or how this
could
be achieved would be great. Thanks.


Sub Do()


On Error Resume Next
Set Xl = GetObject("Excel.Application")
Set wb = Xl.Workbooks("Activities.xls")
If Err < 0 Then Set wb = Xl.Workbooks.Open("c:\My Documents
\Activities.xls"): Err.Clear
wb.Worksheets("Sheet3").Range("A" &
Rows.Count).End(xlUp).Offset(1).Value = UserForm2.txtBy.Value
wb.Worksheets("Sheet3").Range("A" &
Rows.Count).End(xlUp).Offset(0, 1).Value = UserForm2.cmbVote.Value


Xl.Visible = False: AppActivate Xl.Caption
wb.ActiveSheet.Save
Set wb = Nothing: Set Xl = Nothing


End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default transfer data from word userform to excel

It looks like you are using late binding, so the constants you are using
would be unknow and interpreted to have a value of zero:

Sub Do()


On Error Resume Next
Set Xl = GetObject("Excel.Application")
Set wb = Xl.Workbooks("Activities.xls")
If Err < 0 Then Set wb = Xl.Workbooks.Open("c:\My Documents
\Activities.xls"): Err.Clear
wb.Worksheets("Sheet3").Range("A" &
Rows.Count).End(-4162).Offset(1).Value = UserForm2.txtBy.Value
wb.Worksheets("Sheet3").Range("A" &
Rows.Count).End(-4162).Offset(0, 1).Value = UserForm2.cmbVote.Value


Xl.Visible = False: AppActivate Xl.Caption
wb.Save '<=== modified
Set wb = Nothing: Set Xl = Nothing


End Sub


If you want to close Excel, you would need to work in an xl.quit before you
clear the variable.
--
Regards,
Tom Ogilvy


"Jade" wrote:

Hello everyone,

Does anyone know the proper method to transfer data directly from a
word userform to an excel spreadsheet.


I have the code below but am having no success...any feedback to
point
me in the right direction as to what I'm doing wrong or how this
could
be achieved would be great. Thanks.


Sub Do()


On Error Resume Next
Set Xl = GetObject("Excel.Application")
Set wb = Xl.Workbooks("Activities.xls")
If Err < 0 Then Set wb = Xl.Workbooks.Open("c:\My Documents
\Activities.xls"): Err.Clear
wb.Worksheets("Sheet3").Range("A" &
Rows.Count).End(xlUp).Offset(1).Value = UserForm2.txtBy.Value
wb.Worksheets("Sheet3").Range("A" &
Rows.Count).End(xlUp).Offset(0, 1).Value = UserForm2.cmbVote.Value


Xl.Visible = False: AppActivate Xl.Caption
wb.ActiveSheet.Save
Set wb = Nothing: Set Xl = Nothing


End Sub


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
word to excel data transfer help vandy Excel Discussion (Misc queries) 0 February 18th 10 06:42 PM
how can you transfer data from excel to MS word? How do I creat Multiple Personal Folders Excel Discussion (Misc queries) 1 January 2nd 08 03:38 PM
transfer of data from Excel to MS Word amateur Excel Discussion (Misc queries) 2 February 3rd 05 06:48 PM
Transfer Excel data to Word Davwe[_3_] Excel Programming 1 October 20th 03 08:13 PM
Transfer data from EXCEL to WORD Robin Clay[_3_] Excel Programming 4 October 16th 03 07:58 PM


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