Reply
 
Thread Tools Display Modes
  #1   Report Post  
Amanda Allen Amanda Allen is offline
Junior Member
 
Posts: 3
Default Problem with setting the value of DOCVARIABLE

I have a word project that I'm working on in which items are copied from an excel sheet into word using Selection.PasteAndFormat (wdFormatPlainText).
This is a list for a Table of Contents which only has dates (i.e. January 7 - 13, 1999) and a week number.
What I am trying to do is to get the dates and put them into a corresponding Week variable (one that has the dates) that will be in the title line of corresponding pages (52 or 53 pages).

I use the following code:
Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
ActiveDocument.Variables("Week01").Value = Left(Selection.Text, InStr(Selection.Text, vbTab))
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
ActiveDocument.Variables("Week02").Value = Left(Selection.Text, InStr(Selection.Text, vbTab))
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
ActiveDocument.Variables("Week03").Value = Left(Selection.Text, InStr(Selection.Text, vbTab))
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.HomeKey Unit:=wdLine

This code gets the first 2 variables ok, but then starts to skip lines. (ie, week 3 would actually have week 4 value, week 4 would have week 5, week 5 would have week 7)

What an I doing wrong?
Is there a better way to do this?

Any help would be appreciated.
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
DocVariable Paul Mailmerge 2 December 1st 09 08:55 PM
docvariable, template (.dot) Paul Mailmerge 2 October 7th 09 08:56 PM
Registry Policy Setting - Problem Changing Setting JenniferS30 Microsoft Word Help 1 January 14th 08 09:20 PM
Help with FIELD CODES: DOCVARIABLE!!! Wendy D Microsoft Word Help 2 August 16th 05 08:32 PM
Cannot printing DocVariable Field lubo Microsoft Word Help 1 April 9th 05 07:00 AM


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

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"