Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reading Word TextBoxes and Transferring Contents to Excel
So I have all these word documents with the same format. They have all these textboxes that contain "name", "date", "state", "telephone #", etc., respectively. I'm trying to create a database using these .doc files. One way is to manually open all the .doc files and manually type into Excel the name, date, state, telephone, etc into each column. But this is tedious! I'm sure there's a way for Excel to search all the textboxes from Word and automatically transfer it all into one Excel database. I found something on the web that converts Word Comments into Excel. I think it would help in what I'm trying to do: -------------------------------------------------------------- Public Sub PullWordNotes() Dim WordApplication As Word.Application Dim WordDocument As Word.Document Dim DocumentPath As String Dim TargetComment As Word.Comment Dim DestSheet As Worksheet Dim DestRow As Long Set WordApplication = New Word.Application DocumentPath = Application.GetOpenFilename(FileFilter:="Microsoft Word Files (*.doc),*.doc", Title:="Select template narrative Word document") If DocumentPath = "False" Then Exit Sub End If Set WordDocument = WordApplication.Documents.Open(DocumentPath, ReadOnly:=True) Set DestSheet = Sheets("Sheet1") DestSheet.Cells.ClearContents DestSheet.[A1] = "Comment" DestSheet.[B1] = "Referenced Text" DestRow = DestSheet.[A65536].End(xlUp).Row For Each TargetComment In WordDocument.Comments DestSheet.[A2:A65536].Cells(DestRow) = TargetComment.Range.Text DestSheet.[B2:B65536].Cells(DestRow) = TargetComment.Scope.Text Next TargetComment WordDocument.Close False WordApplication.Quit End Sub -------------------------------------------------------------- Now... that just transfers Comments from Word. I'm trying to transfer Text Boxes from Word. I'm knowledgable in VBA, but I cannot frind the TextBox counterpart to Comments. All I found was Controls, ControlCollections, but I don't know how to make it work. Anyone got any suggestions? Thanks -- yl358 ------------------------------------------------------------------------ yl358's Profile: http://www.excelforum.com/member.php...o&userid=35776 View this thread: http://www.excelforum.com/showthread...hreadid=559801 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reading Word TextBoxes and Transferring Contents to Excel
Oh, I also forgot to ask: what do I reference? -- yl358 ------------------------------------------------------------------------ yl358's Profile: http://www.excelforum.com/member.php...o&userid=35776 View this thread: http://www.excelforum.com/showthread...hreadid=559801 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reading Word TextBoxes and Transferring Contents to Excel
Ok I solved the problem for those who want a solution: Dim DestString As String DestString = WordDocument.Shapes("Text Box 7").TextFrame.TextRange.Text Now I have another problem, albeit minor one. The String always ends with a square symbol. It looks like a small, blocky zero and always appears at the end of every string that the .Text method returns. What's up with this? I did the hard part already, so please help! -- yl358 ------------------------------------------------------------------------ yl358's Profile: http://www.excelforum.com/member.php...o&userid=35776 View this thread: http://www.excelforum.com/showthread...hreadid=559801 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Transferring Excel chart into MS Word | Excel Discussion (Misc queries) | |||
Transferring from Excel to Word | Excel Discussion (Misc queries) | |||
Transferring Excel Data to Word Document | Excel Programming | |||
Transferring Excel Data to Word Document | Excel Discussion (Misc queries) | |||
Transferring cell data to textboxes | Excel Programming |