PDA

View Full Version : Solved: Exporting word data to Excel vba



vishwakarma
12-30-2010, 11:15 PM
First of All.. Wishing you all Very Happy and Prosperous New Year..:beerchug:

I've a query, is it possible to export data from word to excel through vba or through any other way(without using any software)...


Thanks...

austenr
12-31-2010, 08:42 AM
hmmmm...last i checked Word and Excel were software. Short of that, mental telepathy maybe?

mikerickson
12-31-2010, 12:33 PM
This worked for me
Sub test()
Dim wordDoc As Object
Set wordDoc = GetObject("Macintosh HD:Users:merickson:Desktop:test.docm")
wordDoc.Application.Selection.wholestory
MsgBox wordDoc.Application.Selection.Text
Set wordDoc = Nothing
End Sub

macropod
12-31-2010, 10:57 PM
Hi Mike,

That looks like software code to me, but I might be mistaken ...

mikerickson
01-01-2011, 07:07 AM
Hi Mike,

That looks like software code to me, but I might be mistaken ...
My bad! :doh:

If I may cop a plea, perhaps the gentleman would have said "new application" had his English been up to it.

Tinbendr
01-03-2011, 09:28 AM
...is it possible to export data from word to excel through vba Yes, but your question is too vague to offer any meaningful solutions.

macropod
01-03-2011, 03:08 PM
My bad! :doh:

If I may cop a plea, perhaps the gentleman would have said "new application" had his English been up to it.Possibly so, but Manoj isn't a newcomer to VBA Express either. He really does need to express himself more clearly.

vishwakarma
01-04-2011, 09:41 PM
Yes, I should have expressed my question more clearly.. sorry for that....

Actually, by "any software" I was indicating to the third party tools/software that we get on other websites through which we can export data from one application to other....

I was looking for this solution through VBA (if there is any)...


Thanks and once again I'm apologetic.

macropod
01-04-2011, 09:50 PM
Hi Manoj,

OK, but you still need to address what Tinbendr said:

Yes, but your question is too vague to offer any meaningful solutions.

vishwakarma
01-04-2011, 10:12 PM
Ok Guys, to be more precise...

I have a word document which contains data in it and I want to import it in an excel file without opening it... Is this doable through VBA...


Thanks...

macropod
01-04-2011, 10:34 PM
Hi Manoj,

Yes, but you still need to give us some details to work with:
Is it a form that 'save data for forms' can be used with?
If not, is there any particular arrangement of the data that are needed when they get into Excel? What about formatting? And so on.

vishwakarma
01-04-2011, 10:53 PM
Ok guys,

I simply need to import data in excel from a particular location. It will be awesome if it can be imported with formatting, otherwise a simple import will do for me… My only concern is to import the data in excel as I have to work on huge data with multiple pages and to copy them I’ve to browse the folders and then paste the data manually in an excel file.




Thanks a lot guys...

macropod
01-04-2011, 11:01 PM
Hi Manoj,

This is starting to sound like you want to process multiple Word files, not just one. Correct?

Do you propose to run this process from Word, or from Excel? Is there a particular reason for your preference (if you have one)?

How are the Word files identified and how are the Excel input ranges identified?

vishwakarma
01-04-2011, 11:12 PM
Hi Macropod,

This is not that I've to process multiple word files but yes mostly I've to. I want to run the vba from excel and there is no particular reason for my preference it is just I want to import the data in excel. I want to import the data in an empty excel file .. range starts from the first cell...


Thanks..

macropod
01-04-2011, 11:47 PM
OK, Here is a very simple Excel macro to copy the contents of whatever Word document is active and paste its contents into whatever Excel worksheet is active. In Excel, you need to set a reference to the Word object library.
Sub Demo()
Dim wdApp As Word.Application
Set wdApp = Word.Application
Dim wdDoc As Word.Document
Set wdDoc = wdApp.ActiveDocument
wdDoc.Range.Copy
ActiveSheet.Paste Destination:=ActiveSheet.Range("A1")
End Sub
Give it a try and let us know if this is the kind of thing you want to do.

Before we can go any further, we'll need to know how the macro is supposed to choose the Word files to process. For example, is it all Word files in a particular folder, or only the files you choose? Is it always the same folder, or can it be different folders?

vishwakarma
01-04-2011, 11:53 PM
Thanks a lot man, u r genius... this is exactly what I was looking for...That will definitely work for me...


THANKS A LOT...:bow:

macropod
01-05-2011, 03:23 AM
Hi Manoj,

You previously said you sometimes need to process multiple documents. If they're all being pasted into the same worksheet, one below the other, you'll need to replace:

ActiveSheet.Paste Destination:=ActiveSheet.Range("A1")with
With ActiveSheet
.Paste Destination:=Range("A" & .Cells.SpecialCells(xlCellTypeLastCell).Row + 1)
End With