Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default excel / word problem

Hi This is half excel related as I am using code to transfer rows of
info to a word doc from excel in a mail merge fashion.

I cant use object lib references so i have to have the bookmarks in word
pre written.

I have a word document and I need to create a number of bookmarks in a
pattern throughout the workbook.

There are 5 bookmarks in the same position on each page and I need to
duplicate this throughout the document. Same page layout, same bookmark
placement but bookmark name incremented by one each time.

I can obviously manage a copy and paste to get the desired amount of
pages but I dont know how to add the bookmarks.

I have posted an attachment with the word doc template in a zip. This
has 3 records / pages within at the moment and the bookmarks are named
in page 1 like this -

AIName1
AIRef1
Operator1
Manager1
Address1
MeterNo1

so the rest of the bookmarks ideally would be the same but with the page
number instead of the 1.

I hope i have posted it clear enough. I know in the past I find it
difficult to explain myself.

Rob



*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default excel / word problem

Hi Rob,

This is Word VBA. Try posting in a Word VBA forum. Once you have
mastered the code you can copy and paste it into Excel and running from
there - but the code and syntax remains Word specific.

With respect to the Excel part of your post, why can't you use object
lib references? And if you choose not to, why do you have to have the
bookmarks prewritten in Word? This isn't the case if you use late binding.

Below I've pasted some hastily scribbled code which creates a new Word
doc and writes in the fields from each column on a separate page of a
Word doc. You could also add Bookmarks (try recording a macro in Word)
but I understood from your email that they were a means to an end for
you - you didn't really need to use bookmarks.

Sub CreateMailMergeyTypeThing()

Dim oW As Object
Dim oDoc As Object
Dim lRow As Long, iCol As Integer

Set oW = GetObject(, "Word.Application")

'create new document
Set oDoc = oW.Documents.Add

'Assuming you have worksheet with 5 fields in columns
With ActiveSheet
lRow = 2
Do While .Cells(lRow, 1) < ""
For iCol = 1 To 5
oW.Selection.TypeText Text:=.Cells(lRow, iCol).Value
oW.Selection.TypeParagraph
Next iCol
oW.Selection.InsertBreak Type:=7 'wdPageBreak
lRow = lRow + 1
Loop
End With

Set oW = Nothing

Set oDoc = Nothing

End Sub



Cheers,
Gareth

PS - People really frown upon the posting on attachments on this NG.



Rob Hardgreaves wrote:
Hi This is half excel related as I am using code to transfer rows of
info to a word doc from excel in a mail merge fashion.

I cant use object lib references so i have to have the bookmarks in word
pre written.

I have a word document and I need to create a number of bookmarks in a
pattern throughout the workbook.

There are 5 bookmarks in the same position on each page and I need to
duplicate this throughout the document. Same page layout, same bookmark
placement but bookmark name incremented by one each time.

I can obviously manage a copy and paste to get the desired amount of
pages but I dont know how to add the bookmarks.

I have posted an attachment with the word doc template in a zip. This
has 3 records / pages within at the moment and the bookmarks are named
in page 1 like this -

AIName1
AIRef1
Operator1
Manager1
Address1
MeterNo1

so the rest of the bookmarks ideally would be the same but with the page
number instead of the 1.

I hope i have posted it clear enough. I know in the past I find it
difficult to explain myself.

Rob



*** Sent via Developersdex http://www.developersdex.com ***

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
DDE problem between Word and Excel Gordon Biggar New Users to Excel 0 October 5th 08 07:20 AM
PROBLEM:How to squeeze 2 Page sized Chart in Excel 2000 & embed in Word 2000 and print from Word to fit one page ??? [email protected] Excel Discussion (Misc queries) 2 September 10th 08 11:07 AM
PROBLEM:How to squeeze 2 Page sized Chart in Excel 2000 & embed in Word 2000 and print from Word to fit one page ??? [email protected] New Users to Excel 2 September 10th 08 11:07 AM
PROBLEM WITH EXCEL TABLE IN WORD mlamin Excel Discussion (Misc queries) 1 January 21st 07 01:52 PM
Word/Excel Integration Problem tuph Excel Discussion (Misc queries) 2 April 12th 06 11:59 PM


All times are GMT +1. The time now is 04:45 PM.

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

About Us

"It's about Microsoft Excel"