Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
DocVariable | Mailmerge | |||
docvariable, template (.dot) | Mailmerge | |||
Registry Policy Setting - Problem Changing Setting | Microsoft Word Help | |||
Help with FIELD CODES: DOCVARIABLE!!! | Microsoft Word Help | |||
Cannot printing DocVariable Field | Microsoft Word Help |