transfer data directly from Word Userform to Excel spreadsheet

J

Jade

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
 
D

Doug Robbins - Word MVP

I suggest that you ask in an Excel newsgroup -
microsoft.public.excel.programming

Userforms can also be created in Excel and if that is where you want the
data that is entered into the form by the user to appear, it would be better
to do the whole thing in Excel.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

Jade

Hi Doug,

I'd rather keep it in Word since I've already did all this work on
it. I thought I could find the answer in this usergroup. All I need
to do is tranfer the data from the word userform to excel
spreadsheet....from your response is it not possible to do?
 
D

Doug Robbins - Word MVP

It's possible, but you are going to find it easier if you don't mix the
applications.

But, see the articles "Control Excel from Word" at:
http://www.word.mvps.org/FAQs/InterDev/ControlXLFromWord.htm

and "Control Word from Excel" at:

http://www.word.mvps.org/FAQs/InterDev/ControlWordFromXL.htm

See the article "Early vs. Late Binding" at:

http://www.word.mvps.org/FAQs/InterDev/EarlyvsLateBinding.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
P

Perry

Here's yr problem
wb.Worksheets("Sheet3").Range("A" & Rows.Count).

In the above statement
Rows.Count
Should read
wb.Worksheets("Sheet3").UsedRange.Rows.Count

Explanation:
Without parent objects, Rows.Count will fail to compile because
it Is Nothing ...

Krgrds,
Perry
 
S

ssk

Hi there

plz help me
i have parse TOC, from TOC, i extracted each section into array like
1.1, 1.1.2, ...3.2.1.. & so on...
Now i take eack section , goto that section and i search my string say
e.g. def[atdcini1] into that section, if found, i output this section
number into my output string array
i want to give output as this string def[actinit[ is present in which
sections, i have to give those sections number

but i dont know how to select text between two sections or heading
i tried using range object methods start, stop, & but my range object
end getting set to end of entire document, & range start also getting
set to entire document

So would anyone plz help me how to select text bewteen two headings
plz

Eagerly waiting for quick reply
Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top