export data from a cell(not the entire cell) to a word document

radu.balak

New Member
Joined
Jun 3, 2010
Messages
5
hy there! i need your help with something that is probable eazy or not :D
I want to export data from a cell(not the entire cell) to a word document, but in a specific place in the word doc.
It's this possible? If the answer is pozitive then how?

Lower u can see from picture exactly what i mean.
http://img337.imageshack.us/img337/4306/exceltoword.jpg

Thanks.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Yes! It's possible!
You must use a bookmarks of word.
From a italian site:
Code:
Sub Esporta_Dati_in_Word()
Application.ScreenUpdating = False
Dim Wrd As Word.Application
Dim Doc As Word.Document
Dim ReplSel As Boolean
Dim i As Integer
On Error Resume Next 'manager errors step by step
'search Word opened
Set Wrd = GetObject(, "Word.Application")
If Err.Number = 429 Then 'if there is an error because Word ins't just open:
'open now
Set Wrd = CreateObject("Word.Application")
End If
On Error GoTo 0 'replace control errors
Wrd.Visible = True
Wrd.Activate
ReplSel = Wrd.Options.ReplaceSelection
Wrd.Options.ReplaceSelection = True
Set Doc = Wrd.Documents.Open("C:\Documents and Settings\Users\Desktop\Prova.doc")    'path                                                                              Worksheets("Foglio1").Activate
i = ActiveCell.Row
Doc.Bookmarks("Prova").Select 'name of bookmarks
If Cells(i, 4) <> Empty Then  'change rif cell with exact rif
Wrd.Selection.TypeText Cells(i, 4).Value
Else
Wrd.Documents.Close
Wrd.Visible = False
End If
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks a lot. I forget to tell that i'm a beginner :) If there is someone here to explain me step by step how to do this i will have a great gratitude for him :D
 
Upvote 0
For this code:
You open excel... CTRL + F11 opens editor VBA.
You copy this code in a "module" that you insert by menù Insert.
Modify this piece: Set Doc = Wrd.Documents.Open("C:\Documents and Settings\Users\Desktop\Prova.doc") with your path word file.
Before... you put bookmarks in word by menù Insert where you need to have values cells excel. you name a bookmarks
After this, if your data is in A1:
Cells(1, 1).select
Wrd.Selection.TypeText Cells(1, 1).Value
Wrd.Documents.Close
Wrd.Visible = False

and so...
 
Upvote 0
Thanks again. In my VBA the macros stop at the first dim: Dim Wrd As Word.Application with the error : User-defined type not defined. Were is the problem please?
 
Upvote 0
Thanks again. In my VBA the macros stop at the first dim: Dim Wrd As Word.Application with the error : User-defined type not defined. Were is the problem please?
Have you modified this piece of code:
Code:
Set Doc = Wrd.Documents.Open("C:\Documents and Settings\Users\Desktop\[COLOR=red]Prova.doc[/COLOR]")
with your path and name of your word document??
 
Upvote 0
ok!!
I have forgotten one thing.
In VBA Editor of Excel ---> Tools ---> Refers ---> Check Microsoft Word 12.0 (10.0 for excel 2003) Object Library.
Now try...
 
Last edited:
Upvote 0
Hello @ machopicho,

Thanks for your code.
Would you please tell me how to copy "00" to word file if excell cell value is zero or empty.

Thanks
sadi
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,194
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top