Need fields/code to switch paragraphs

G

Grd

Hi,

I've written a computer manual in Word (150 page document). Now there is
another newer version of the program so I need to update my word document
with new screenshots and modify a few paragraphs.

I still need the old version so I need the document to have both versions.
(I want to keep one document so I don't have to keep track of changes I make
to common paragraphs).

I've inserted the new screenshots and substitue paragrahs and formatted them
as hidden text. When I need to print the new version of the manual I will
unhide them and hide the original paragrahs and the reverse when i need the
old version. Its a lot of work because there are about 50 new
paragraphs/screenshots.

I'm looking for some guidance as to how to use field codes (and maybe VBA)
to be able to switch between the old and the new.

Any guidance would be great.

Tx

Grd
 
G

Graham Mayor

Personally I would create the manuals as two documents and maintain the
common variable text in a third and use includetext fields to insert
bookmarked segments of the third document into the others. You would still
only have one document to maintain.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Grd

Hi Graham,

Thanks for the response.

The vast majority of the documents is common between the two so perhaps I
should use the includetext fields for the other documents.
So I would perhaps have two includetext fields (one for the original and one
for the new). I could then rename the orginal word document so it wouldn't
find the path when I update the document that way only one of the includetext
fiels would show. Then reverse it.

I will play with the includetext. I found some info at an MVP site:
http://daiya.mvps.org/includetext.htm

Tx

Grd
 
G

Graham Mayor

You only need 2 documents to do it that way, one containing bookmarked
variations the other the master document. You can then switch between the
versions using an ASK field and a series of conditional fields to insert the
appropriate bookmarks eg

{ ASK Version "Enter Version '1' or '2'" \d 1 }
{ IF { REF Version } = 1 { INCLUDETEXT "D:\\My Documents\\Word
Documents\\Versions.docx" Version1A } { INCLUDETEXT "D:\\My Documents\\Word
Documents\\Versions.docx" Version2A }}


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Grd

I will try that out. Looks like it will work.

G

Graham Mayor said:
You only need 2 documents to do it that way, one containing bookmarked
variations the other the master document. You can then switch between the
versions using an ASK field and a series of conditional fields to insert the
appropriate bookmarks eg

{ ASK Version "Enter Version '1' or '2'" \d 1 }
{ IF { REF Version } = 1 { INCLUDETEXT "D:\\My Documents\\Word
Documents\\Versions.docx" Version1A } { INCLUDETEXT "D:\\My Documents\\Word
Documents\\Versions.docx" Version2A }}


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Grd

Hi Graham,

Just thought I'd complete the thread. I was finding the seperate documents a
lot of work so I created some 'rough' VBA code to hide and unhide the
relevant paragraphs. The basic idea is that all the new paragraphs are
bookmarked with a name prefixed with BB and the old paragraphs are named with
a prefix AA. (The acutal versions of the program I'm documenting are XI and
2008.) Then I have code that loops through looking for BB and AA and hides
one and shows the other. Works OK at the moment.

Thanks again for you help.

Below is my code

Grd
Option Explicit

Sub Version_2008()
SwitchVersion ("BB")
End Sub

Sub Version_XI()
SwitchVersion ("AA")
End Sub

Sub SwitchVersion(Version
'=============================================================================================
' Used to switch versions by unhiding and hiding relevant paragraph
'=============================================================================================
Dim LineNumber As Integer
Dim PageNumber As String
'Determine where we are so we can get back later
LineNumber = Selection.Information(wdFirstCharacterLineNumber)
ActiveWindow.ActivePane.View.ShowAll = False 'Need to determine page
number correctly
PageNumber = Selection.Information(wdActiveEndPageNumber)
'No need to see the screen
Application.ScreenUpdating = False
'Need to have show codes on for this to work
ActiveWindow.ActivePane.View.ShowAll = True
Dim i As Integer
For i = 1 To ActiveDocument.Bookmarks.Count
Selection.GoTo What:=wdGoToBookmark,
Name:=ActiveDocument.Bookmarks(i).Name
Selection.Font.Hidden = Not (ActiveDocument.Bookmarks(i).Name
Like Version & "*")
Next i
ActiveWindow.ActivePane.View.ShowAll = False
'back to where we where
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:=PageNumber
'Selection.GoTo What:=wdGoToLine, Which:=wdGoToFirst, Count:=LineNumber,
Name:=""
End Sub

Sub CreateNewBookmark_XI(
'=============================================================================================
' Creates another bookmark for the version XI (AA
'=============================================================================================
ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="AA" &
(GetNewNumber("AA"))
Selection.Font.Hidden = True
End Sub

Sub CreateNewBookmark_08(
'=============================================================================================
' Creates another bookmark for the version 2008 (BB
'=============================================================================================
ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="BB" &
(GetNewNumber("BB"))
Selection.Font.Hidden = True
End Sub

Function GetNewNumber(Version As String
'=============================================================================================
' Finds the Last Bookmark so we can use this for the next Bookmark numbe
'=============================================================================================
Dim BM As Bookmarks
Dim BM_Nbr As Integer
Dim i As Integer
Dim Highest As Integer
Set BM = ActiveDocument.Bookmarks
'Loop through bookmarks checking for highest number
For i = 1 To BM.Count
If BM(i).Name Like Version & "*" Then
BM_Nbr = Val(Mid(BM(i).Name, 3))
If Highest < Val(Mid(BM(i).Name, 3)) Then Highest = BM_Nbr
End If
Next
GetNewNumber = Highest + 1
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top