Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
I have several word documents being emailed to me containing tables. I would
like to be able to import some of the data in the word table into a cell in my spreadsheet. Is this possible using a macro in the spreadsheet? -- Trefor |
#2
![]() |
|||
|
|||
![]() hi Trefor, Yes, that's one of the advantages of the MS Office Family! Look in Excel VBA help "Controlling One Microsoft Office Application from Another". A quick search in Google found this: http://www.mindspring.com/~tflynn/ex...html#Open_Word. You'd replace the "With mywdRange" with code appropraite to your problem. It's fairly straight-forward if you know Word VBA. Once word is open use: Selection.Tables(1).Select ' goes to a specified table occurence Selection.SelectRow Selection.Copy The switch back to Excel and Paste. HTH Art -- HiArt ------------------------------------------------------------------------ HiArt's Profile: http://www.excelforum.com/member.php...o&userid=19953 View this thread: http://www.excelforum.com/showthread...hreadid=472033 |
#3
![]() |
|||
|
|||
![]()
Thankyou for the reply, but I must be missing something here. I am still
learning about macros/VBA in Excel and no nothing about macros/VBA in Word. I tried to run the code and got an error: Dim wdApp As Word.Application User-defined type not defined. -- Trefor "HiArt" wrote: hi Trefor, Yes, that's one of the advantages of the MS Office Family! Look in Excel VBA help "Controlling One Microsoft Office Application from Another". A quick search in Google found this: http://www.mindspring.com/~tflynn/ex...html#Open_Word. You'd replace the "With mywdRange" with code appropraite to your problem. It's fairly straight-forward if you know Word VBA. Once word is open use: Selection.Tables(1).Select ' goes to a specified table occurence Selection.SelectRow Selection.Copy The switch back to Excel and Paste. HTH Art -- HiArt ------------------------------------------------------------------------ HiArt's Profile: http://www.excelforum.com/member.php...o&userid=19953 View this thread: http://www.excelforum.com/showthread...hreadid=472033 |
#4
![]() |
|||
|
|||
![]()
Click on Tools|References
Then scroll down looking for: Microsoft Word xx.0 Object library (xx.0 will change with the version of word/office you have.) Trefor wrote: Thankyou for the reply, but I must be missing something here. I am still learning about macros/VBA in Excel and no nothing about macros/VBA in Word. I tried to run the code and got an error: Dim wdApp As Word.Application User-defined type not defined. -- Trefor "HiArt" wrote: hi Trefor, Yes, that's one of the advantages of the MS Office Family! Look in Excel VBA help "Controlling One Microsoft Office Application from Another". A quick search in Google found this: http://www.mindspring.com/~tflynn/ex...html#Open_Word. You'd replace the "With mywdRange" with code appropraite to your problem. It's fairly straight-forward if you know Word VBA. Once word is open use: Selection.Tables(1).Select ' goes to a specified table occurence Selection.SelectRow Selection.Copy The switch back to Excel and Paste. HTH Art -- HiArt ------------------------------------------------------------------------ HiArt's Profile: http://www.excelforum.com/member.php...o&userid=19953 View this thread: http://www.excelforum.com/showthread...hreadid=472033 -- Dave Peterson |
#5
![]() |
|||
|
|||
![]()
Dave, thankyou that fixed that problem, but the bigger issue I am still
having problems with. I have searched around here and found many people looking for the same thing (using keywords: grab, copy, import, extract) To explain what I am trying to do in more detail: (using Office 2003) I would like to run a macro in Excel that: 1. Checks to see if there is an open Word document. (I dont want to specify a name or have to open the file from within Excel) 2. Select and copy the data from word to excel. (The word documents (for some reason beyond my control) have text boxes set in autoshapes to look like tables, each cell within the €śtable€ť has a text box and the text box has several lines of text in it (names and addresses for example)) 3. I am guessing for simplicity it would be easier to just grab everything, then paste it into a "scratch" area in excel, and then I can pick and choose what I want from the scratch area. I am fairly happy with macro's/VBA in excel, what I am not familiar with is VBA in Word or switching between the two. Any help very much appreciated. -- Trefor "Dave Peterson" wrote: Click on Tools|References Then scroll down looking for: Microsoft Word xx.0 Object library (xx.0 will change with the version of word/office you have.) Trefor wrote: Thankyou for the reply, but I must be missing something here. I am still learning about macros/VBA in Excel and no nothing about macros/VBA in Word. I tried to run the code and got an error: Dim wdApp As Word.Application User-defined type not defined. -- Trefor "HiArt" wrote: hi Trefor, Yes, that's one of the advantages of the MS Office Family! Look in Excel VBA help "Controlling One Microsoft Office Application from Another". A quick search in Google found this: http://www.mindspring.com/~tflynn/ex...html#Open_Word. You'd replace the "With mywdRange" with code appropraite to your problem. It's fairly straight-forward if you know Word VBA. Once word is open use: Selection.Tables(1).Select ' goes to a specified table occurence Selection.SelectRow Selection.Copy The switch back to Excel and Paste. HTH Art -- HiArt ------------------------------------------------------------------------ HiArt's Profile: http://www.excelforum.com/member.php...o&userid=19953 View this thread: http://www.excelforum.com/showthread...hreadid=472033 -- Dave Peterson |
#6
![]() |
|||
|
|||
![]()
This will check to see if MSWord is running and check to see if there's an
active document in word: Option Explicit Sub testme01() Dim WDApp As Object Dim WDDoc As Object Set WDApp = Nothing On Error Resume Next Set WDApp = GetObject(, "Word.Application") If Err.Number < 0 Then MsgBox "Word isn't running!" Exit Sub End If WDApp.Visible = True 'at least for testing, just to make sure Set WDDoc = Nothing On Error Resume Next Set WDDoc = WDApp.activedocument On Error GoTo 0 If WDDoc Is Nothing Then MsgBox "No activedocument in Word" Exit Sub End If End Sub When I need to do stuff in word, I usually record a macro when I do it manually. Then I struggle to make it work the way I want. If you do that and still have trouble, you can post back--or post to an MSWord newsgroup. Trefor wrote: Dave, thankyou that fixed that problem, but the bigger issue I am still having problems with. I have searched around here and found many people looking for the same thing (using keywords: grab, copy, import, extract) To explain what I am trying to do in more detail: (using Office 2003) I would like to run a macro in Excel that: 1. Checks to see if there is an open Word document. (I dont want to specify a name or have to open the file from within Excel) 2. Select and copy the data from word to excel. (The word documents (for some reason beyond my control) have text boxes set in autoshapes to look like tables, each cell within the €śtable€ť has a text box and the text box has several lines of text in it (names and addresses for example)) 3. I am guessing for simplicity it would be easier to just grab everything, then paste it into a "scratch" area in excel, and then I can pick and choose what I want from the scratch area. I am fairly happy with macro's/VBA in excel, what I am not familiar with is VBA in Word or switching between the two. Any help very much appreciated. -- Trefor "Dave Peterson" wrote: Click on Tools|References Then scroll down looking for: Microsoft Word xx.0 Object library (xx.0 will change with the version of word/office you have.) Trefor wrote: Thankyou for the reply, but I must be missing something here. I am still learning about macros/VBA in Excel and no nothing about macros/VBA in Word. I tried to run the code and got an error: Dim wdApp As Word.Application User-defined type not defined. -- Trefor "HiArt" wrote: hi Trefor, Yes, that's one of the advantages of the MS Office Family! Look in Excel VBA help "Controlling One Microsoft Office Application from Another". A quick search in Google found this: http://www.mindspring.com/~tflynn/ex...html#Open_Word. You'd replace the "With mywdRange" with code appropraite to your problem. It's fairly straight-forward if you know Word VBA. Once word is open use: Selection.Tables(1).Select ' goes to a specified table occurence Selection.SelectRow Selection.Copy The switch back to Excel and Paste. HTH Art -- HiArt ------------------------------------------------------------------------ HiArt's Profile: http://www.excelforum.com/member.php...o&userid=19953 View this thread: http://www.excelforum.com/showthread...hreadid=472033 -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I import formmail data to a custom excel template? | Excel Worksheet Functions | |||
Excel data not transfering to Word. Colums are expanded. | New Users to Excel | |||
Macro - Open Word with Excel macro | Excel Discussion (Misc queries) | |||
exporting excel worksheet to word | Links and Linking in Excel | |||
Can Excel Export Data to Word Format? | Excel Discussion (Misc queries) |