#  Other Applications & Softwares  > Word Formatting & General >  >  Copy text from activeX textbox and paste into excel

## montecarlo2079

Hi I need a macro that will loop through each active X textbox within a word doc and copy only the text to a cell in excel.

This is what I have so far and its not working.




```
Please Login or Register  to view this content.
```

----------


## Tinbendr

Welcome to the board.

Not tested.




```
Please Login or Register  to view this content.
```

----------


## montecarlo2079

hey thanks for responding.

im getting run time error, object required on this line

.Range(.Cells(1, Counter)) = oTB.Text

----------


## Tinbendr

Ahk!  Should be 


```
Please Login or Register  to view this content.
```

----------


## montecarlo2079

same run time error 424, object required.

do I need to set some type of reference?

----------


## Tinbendr

Wow, I'm not focusing this morning.



```
Please Login or Register  to view this content.
```

----------


## montecarlo2079

im getting compile error, method or data member not found.

this project is killing me and I appreciate the help!

----------


## Tinbendr

OK, try taking the .text off the end and press the period and see what options are available. (Value maybe)

Maybe even leave the end off and see if the default will work.



```
Please Login or Register  to view this content.
```

----------


## montecarlo2079

ok so I changed it to this

.Cells(Counter, 1) = oCtl.OLEFormat.Object

now my next problem.

how do I get it to paste across the row and not down the column?

and you are awesome for helping me

----------


## Tinbendr

```
Please Login or Register  to view this content.
```

----------


## montecarlo2079

Here is another version of the code I Am playing with.

can you take a look and tell me how I Can use this to paste across the rows?




```
Please Login or Register  to view this content.
```

----------


## Tinbendr

You just have to increment the columns element of the Cells object.




```
Please Login or Register  to view this content.
```

----------


## montecarlo2079

AWESOME!

thank you so much,.

now I have a second part to this macro.

I need to loop through all the word docs in a specified folder and perform this code on it.

do you have any code that can do that?

----------


## Tinbendr

If your goal is to import all the textboxes into excel, then just write it from Excel.

Change path as required.




```
Please Login or Register  to view this content.
```

----------


## montecarlo2079

the problem is I need to run it from word.

The other problem I am having is that when I run this code,  it pastes the next document in the same row when I need each document to be pasted in a different row




```
Please Login or Register  to view this content.
```

----------


## Tinbendr

Try changing this 


```
Please Login or Register  to view this content.
```


 to this 


```
Please Login or Register  to view this content.
```


Sometimes the parameters aren't transcribed correctly.

----------


## montecarlo2079

for some reason it pasted the items and then they were cleared out.

here is what I Am doing.

open 1 word doc
copy each active x textbox contents
paste it into a row in excel

open the next word doc
copy each active x textbox contents
paste it into a row in excel


for some reason when it loops to the next document it doesnt paste to the next row, it continues on the same row going across.

so document 1 should be on row 1
document 2 should be on row 2 and so forth.

any ideas?

----------


## Tinbendr

Maybe



```
Please Login or Register  to view this content.
```

----------


## montecarlo2079

hmmm

that didnt work either.

The original code from my last post on the previous page works the best.

I think that within the counter or the pasting porting into excel, its telling it to always paste into the first row.

how can I convert it to start by finding the next empty cell in column A, and then pasting the info.

----------


## Tinbendr

What's the post number?  (Far right side in the color banner.)

----------


## montecarlo2079

15 is the post number

----------


## Tinbendr

Move the 


```
Please Login or Register  to view this content.
```


 to the top of the module.

----------


## montecarlo2079

nope, didnt change anything

can we change the counter to some type of offset to make it go to the next open row?
\

----------


## Tinbendr

Oops, sorry.  The Counter = 0 was inside the loop.  We have to more it outside.  Here's the code again.




```
Please Login or Register  to view this content.
```

----------


## montecarlo2079

hmmm that still did the same thing.

----------


## Tinbendr

OK try this.  I moved the lastrow to outside the loop and added manual counter increment.



```
Please Login or Register  to view this content.
```

----------


## montecarlo2079

ok what it did was this

Name
        Address
                    DOB
                          Ranking

then the 2nd document started in column BT and did the same thing.

sorry it didnt post,  the items were staggered
a1
b2
c3
d4
e5

----------


## Tinbendr

After this 


```
Please Login or Register  to view this content.
```


Add this 


```
Please Login or Register  to view this content.
```

----------


## montecarlo2079

what its doing is staggering the results.

a1, b2, c3

its not going straight across.

also its still not skipping to the next open row in excel

----------


## Tinbendr

I must have hit an undo or something, because I'm sure I moved the counter to outside the for-next earlier.




```
Please Login or Register  to view this content.
```

----------

