Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default How do I import Word bookmarks into Excel cells

I would like to create an Excel database by importing information for each
record (row) from about 30 different bookmarks in each Word document
populating designated columns at the next available row at the bottom of the
data table. I anticipate that the data base will contain a record (row) for
each of about 50 different Word documents.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default How do I import Word bookmarks into Excel cells

one way:

Dim oWord As Word.Application
Dim oDoc As Word.document
Dim vBkMarks As Variant
Dim vRecord
Dim rRecord As Range
Dim nFields As Long
Dim i As Long

vBkMarks = Array("Bookmark1", "Bookmark2", "Bookmark3") 'etc...
ReDim vRecord(LBound(vBkMarks) To UBound(vBkMarks))
nFields = UBound(vBkMarks) - LBound(vBkMarks) + 1
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
On Error GoTo 0
If oWord Is Nothing Then _
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.ActiveDocument
For i = LBound(vBkMarks) To UBound(vBkMarks)
vRecord(i) = oDoc.Bookmarks(vBkMarks(i)).Range.Text
Next i
With Sheets("DataTable")
.Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0).Resize( _
1, nFields).Value = vRecord
End With


In article ,
Glen wrote:

I would like to create an Excel database by importing information for each
record (row) from about 30 different bookmarks in each Word document
populating designated columns at the next available row at the bottom of the
data table. I anticipate that the data base will contain a record (row) for
each of about 50 different Word documents.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How do I import Word bookmarks into Excel cells

First, this may not help a bit...

MSWord has an option under Tools|Options|Save Tab:
Save data only for forms

From MSWord's help for that option.

Save data only for forms Saves the data entered into an online form as a
single, tab-delimited text file in plain text format. You can then import the
contents of that file into a database for analysis.

It may be something to consider if you're not too far into your project.

(If you have followups, you may want to ask in an MSWord newsgroup, though.)

Glen wrote:

I would like to create an Excel database by importing information for each
record (row) from about 30 different bookmarks in each Word document
populating designated columns at the next available row at the bottom of the
data table. I anticipate that the data base will contain a record (row) for
each of about 50 different Word documents.


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default How do I import Word bookmarks into Excel cells

Thanks for the information. The bookmarks are already in Word documents
provided by others that I have no influence over. But your information could
be valuable in some other projects in the future. Thanks again.

"Dave Peterson" wrote:

First, this may not help a bit...

MSWord has an option under Tools|Options|Save Tab:
Save data only for forms

From MSWord's help for that option.

Save data only for forms Saves the data entered into an online form as a
single, tab-delimited text file in plain text format. You can then import the
contents of that file into a database for analysis.

It may be something to consider if you're not too far into your project.

(If you have followups, you may want to ask in an MSWord newsgroup, though.)

Glen wrote:

I would like to create an Excel database by importing information for each
record (row) from about 30 different bookmarks in each Word document
populating designated columns at the next available row at the bottom of the
data table. I anticipate that the data base will contain a record (row) for
each of about 50 different Word documents.


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default How do I import Word bookmarks into Excel cells

JE McGimpsey,
Thank you for your reply to my Bookmark question. It has been so long since
I worked with VB that I could not get the copy/pasted version of your code
inserted properly into Excel. I will keep trying to get the code in
properly. Thanks again for your help.
Glen

"JE McGimpsey" wrote:

one way:

Dim oWord As Word.Application
Dim oDoc As Word.document
Dim vBkMarks As Variant
Dim vRecord
Dim rRecord As Range
Dim nFields As Long
Dim i As Long

vBkMarks = Array("Bookmark1", "Bookmark2", "Bookmark3") 'etc...
ReDim vRecord(LBound(vBkMarks) To UBound(vBkMarks))
nFields = UBound(vBkMarks) - LBound(vBkMarks) + 1
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
On Error GoTo 0
If oWord Is Nothing Then _
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.ActiveDocument
For i = LBound(vBkMarks) To UBound(vBkMarks)
vRecord(i) = oDoc.Bookmarks(vBkMarks(i)).Range.Text
Next i
With Sheets("DataTable")
.Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0).Resize( _
1, nFields).Value = vRecord
End With


In article ,
Glen wrote:

I would like to create an Excel database by importing information for each
record (row) from about 30 different bookmarks in each Word document
populating designated columns at the next available row at the bottom of the
data table. I anticipate that the data base will contain a record (row) for
each of about 50 different Word documents.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default How do I import Word bookmarks into Excel cells

Take a look he

http://www.mvps.org/dmcritchie/excel/getstarted.htm


In article ,
Glen wrote:

Thank you for your reply to my Bookmark question. It has been so long since
I worked with VB that I could not get the copy/pasted version of your code
inserted properly into Excel. I will keep trying to get the code in
properly.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default How do I import Word bookmarks into Excel cells

JE McGimpsey
I am making progress. I got an error message. The message was "Compile
error: User-defined type not defined".

"JE McGimpsey" wrote:

Take a look he

http://www.mvps.org/dmcritchie/excel/getstarted.htm


In article ,
Glen wrote:

Thank you for your reply to my Bookmark question. It has been so long since
I worked with VB that I could not get the copy/pasted version of your code
inserted properly into Excel. I will keep trying to get the code in
properly.


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default How do I import Word bookmarks into Excel cells

Yup - forgot to state that you need to set a reference to the Word
object library. With your project selected in the VBE, choose
Tools/References... and select the Word XX Object library from the
dialog.


In article ,
Glen wrote:

I am making progress. I got an error message. The message was "Compile
error: User-defined type not defined".

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import cells from excel into word and create multiple word docs scdaddy7269 Excel Programming 2 March 20th 06 07:03 PM
Copy from Excel to bookmarks in Word [email protected] Excel Programming 4 March 6th 06 01:08 PM
Excel and Word Bookmarks JFamilo[_7_] Excel Programming 1 July 14th 05 05:13 AM
exporting Excel data to Word using Bookmarks Dave Kilroy Excel Programming 0 May 19th 05 05:33 PM
VBA, Bookmarks, Word and Excel... help please! [email protected] Excel Programming 2 February 13th 05 09:03 PM


All times are GMT +1. The time now is 11:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"