Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts

    convert 'old' template doc to 'new' template (All)

    Hi,

    Few questions regarding conversion of a document created using 'old' template to a 'new'ly created blank document.

    Background: Creating a new template (changes in company names + lots of other features etc) Upgrading 'old' template to a 'new' template. Therefore, need to convert the document created with 'old' template to the 'new' template.

    The conversion process needs to do the following:

    1. When a user open a document created using 'old' template - display a dialog to say convert doc to the 'new' template - user clicks OK (know how to do this)
    2. Open a blank document using the 'new' template (not sure how to do this under VBA)
    3. Copy custom document properties and document variables to the newly created blank document (I was thinking of doing something like this for
    each custom property: ConvertTo.CustomDocumentProperties(sTitle1).value = convertFrom.CustomDocumentProperties(sTitle1).valu e, etc)
    4. Copy a table from 'old' document to 'new' document (blank table already in the new document):
    Do I delete the table and then somehow copy it from the old document or do I copy specific rows?)
    5. Replace section 4 of the 'new' document with the contents of the 'old' document (from section 4 to n-1)
    6. Once all the contents have been copied, backup the current 'old' document and then save the 'new' document with the name of the 'old' document

    I have probably asked too much already. I know how to do some of the 1, 3, 4 (by copying specific rows - don't know how to replace the whole table), 6 (don't know how to create a backup).

    Any help/pointers very gratefully accepted. Thanks in advance.

    Robie
    Thanks.
    Robie

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: convert 'old' template doc to 'new' template (All)

    Wouldn't it be easier to attach the old document to the new template

    ActiveDocument.AttachedTemplate = ...

    and then use Selection.Find to find and replace items that need to be changed?

  3. #3
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: convert 'old' template doc to 'new' template (All)

    Thanks Hans but perhaps expand a bit as to what you mean. Very interesting thought - you have got me thinking now. <img src=/S/smile.gif border=0 alt=smile width=15 height=15> Thanks.

    Are you saying that when a user opens an 'old' document, we change the attached template to point to the 'new' template & then save the document? But the old document contains, for example front cover (section 1), back cover (last section) - these will be different in the 'new' template. The front cover will probably look totally different to the 'old' template & so on. Will the fields (like title1, title2 etc) be updated automatically?

    Can the change of the attached template be done under AutoOpen or DocumentBeforeOpen?

    Thanks Hans. Look forward to bit more detail. This is good.

    Robie
    Thanks.
    Robie

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: convert 'old' template doc to 'new' template (All)

    You could switch the template in an AutoOpen macro. However, this will not change items such as a cover page; you'd have to do that separately

  5. #5
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: convert 'old' template doc to 'new' template (All)

    I don't think that solves my problem because I only need sections 2 & 4 to n-1 from the old document - rest I would want to keep from the 'new' document.

    Section 1= Cover Page
    Section 2= Change History
    Section 3= TOC
    Section 4 to (n-1) = User Content
    Section n (last section) = Back Cover

    Hope that make sense.

    Robie
    Thanks.
    Robie

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: convert 'old' template doc to 'new' template (All)

    Your original plan might be better.

    About 2: you create a new document like this:

    Dim docNew As Document
    Set docNew = Documents.Add(Template:="...")

    About 4: you can copy and paste an entire table. You'd have to delete the table in the target document first. Let's say it is the 3rd table in the document.

    Dim rng As Range
    Set rng = docNew.Tables(3).Range
    docNew.Tables(3).Delete
    docOld.Tables(3).Range.Copy
    rng.Paste

    About 5: you can copy entire sections. For example

    Dim i As Integer
    For i = 4 To docOld.Sections.Count - 1
    docOld.Sections(i).Range.Copy
    docNew.Sections(i).Range.Paste
    Next i

    About 6: you can create a copy of the old document from Word by using

    docOld.SaveAs "..."

    or you can close it, and use the FileCopy instruction to copy the file.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •