Results 1 to 15 of 15
  1. #1
    Lounger
    Join Date
    Jul 2006
    Location
    N. Highlands, California, USA
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Copy a cell and not a table? (Word 2003)

    Good Morning,

    I have attached a form that I have been working on forever <img src=/S/bash.gif border=0 alt=bash width=35 height=39> . I used the record a macro feature to automate a few of the things I need this form to do.
    1. When the user "tabs" out of the notes form field I would like another page added. The add "a page macro" (which I think I got from this site <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23> ) works perfectly.
    2. I need the cursor to return to the notes section on the 2nd page. I created the "move it" macro to do just that.
    3. I need only the title, date, notes section, and confidential information on the second page. I created the "merge" macro to delete and merge all the other fields. For some reason this macro also adds another page.
    All the macros 'work' on their own, but I need them to all be one function when the user tabs out of the notes section on the first page. I don't know how to combine all the macros into one.

    I feel like I am going about this the completely wrong way, so any help at all would be appreciated. My dream would be for the form to work like this:
    The user would fill in all the required information and complete the notes section.
    When the user got to the bottom of the notes section they could tab out to add another page if needed.
    The 2nd page would only have the title, date, notes, and confidential information sections.

    Thank you for your help!
    Attached Files Attached Files

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

    Re: Copy a cell and not a table? (Word 2003)

    Is this form to be used within your organization, or is it intended to be sent out to people outside your organization?

  3. #3
    Lounger
    Join Date
    Jul 2006
    Location
    N. Highlands, California, USA
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copy a cell and not a table? (Word 2003)

    Thanks for responding Hans.

    This form will be completed by members of my organization but the completed (printed) form will be forwarded to people outside the organization.

    Warm Regards,

    SME

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

    Re: Copy a cell and not a table? (Word 2003)

    If the form is to be completed within your organization, I would recommend the following:
    - Save your form as a template (.dot).
    - Insert a page break at the end of the first page.
    - Create the second page table manually.
    - Select the page break together with the second page table, and create an AutoText entry for it. Make sure that it is saved in the template, not in your Normal.dot.
    - Now delete the page break and table again.
    - Use the add_page macro you already have to unprotect the document, insert the AutoText entry and to protect the document again.

    To insert an AutoText entry using code:
    <code>
    ActiveDocument.AttachedTemplate.AutoTextEntries("N ameOfEntry").Insert _
    Where:=Selection.Range, RichText:=True
    </code>
    This way, your code doesn't have to do any manipulation of the table or its cells, it only inserts the existing AutoText entry.

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

    Re: Copy a cell and not a table? (Word 2003)

    I forgot to mention: make the template available to the users either by letting them copy it to their User Templates folder, or by placing it in a shared network folder.
    When they need the form, they can create a new document based on the template. The macros and AutoText entry will be available in the new document.

  6. #6
    Lounger
    Join Date
    Jul 2006
    Location
    N. Highlands, California, USA
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copy a cell and not a table? (Word 2003)

    Hi Hans,

    Great suggestion, but I don't think I am implementing it properly because I am getting an error message:
    Run Time Error 5941 The requested member of the collection does not exist. or
    Run Time Error 5981 Cannot open macro storage

    My add a page code now looks like this:

    Sub add_page()

    If ActiveDocument.ProtectionType <> wdNoProtection Then
    ActiveDocument.Unprotect Password:="summer"
    End If

    Dim pass
    Dim table_num As Integer
    Dim i As Integer

    With ActiveDocument.Tables(table_num)
    .Select
    Selection.Fields.Update
    End With

    ActiveDocument.AttachedTemplate.AutoTextEntries("A ddPage").Insert _
    Where:=Selection.Range, RichText:=True


    If ActiveDocument.ProtectionType = wdNoProtection Then
    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
    NoReset:=True
    End If


    End Sub


    I have saved the form as a document template. This is my first time working with Auto Text. Your guidance is appreciated.

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

    Re: Copy a cell and not a table? (Word 2003)

    Perhaps you didn't name the AutoText entry "AddPage".

    I have attached a (zipped) sample template with an AutoText entry.
    Attached Files Attached Files

  8. #8
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Copy a cell and not a table? (Word 2003)

    You have the line
    <code>With ActiveDocument.Tables(table_num)</code>

    You haven't set the value of table_num, so it will be using an initial value of 0, and since ActiveDocument.Tables(0) doesn't exist you get the error. Try setting table_num to the correct value.

    StuartR

  9. #9
    Lounger
    Join Date
    Jul 2006
    Location
    N. Highlands, California, USA
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copy a cell and not a table? (Word 2003)

    Thank you both for your suggestions.

    Hans, you were correct in your assumption that I did not have my Auto Text entry named "Add Page".

    I'm going to try and apply my new knowledge to the form and will post with an update.

    Thank you!


    Warm Regards,

    Summer

  10. #10
    Lounger
    Join Date
    Jul 2006
    Location
    N. Highlands, California, USA
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copy a cell and not a table? (Word 2003)

    Good Afternoon,

    Everything works perfectly, in document form. But when I save it to a template the AddTable macro/auto text gives me an error message. I think it's because the auto text is saved to my Normal.dot and not the template. When I try to copy the auto text over to the template I get an error message "Cannot attach document to protected template" I can only assume it is referring to the normal.dot.

    I tried recreating the form and the auto text, but I can't get the auto text to save any where else but the normal.dot. I need everything to work in a template and for that template to be mobile.

    Please tell me what I am doing wrong.

    Warm Regards,

    Summer

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

    Re: Copy a cell and not a table? (Word 2003)

    Your template is protected for forms. If you want to modify it, for example add an AutoText entry, you must temporarily unprotect it, apply the changes, then protect it again before saving it.

  12. #12
    Lounger
    Join Date
    Jul 2006
    Location
    N. Highlands, California, USA
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copy a cell and not a table? (Word 2003)

    After you said that it actually worked <img src=/S/cool.gif border=0 alt=cool width=15 height=15> .

    But when I unprotect the template and then add the auto text and reprotect the template, I can't resave the template without losing the auto text. Any Suggestions?

    Warm Regards,

    Summer

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

    Re: Copy a cell and not a table? (Word 2003)

    Protecting the template shouldn't cause the AutoText entry to be lost. Are you absolutely sure you stored it in the template?

  14. #14
    Lounger
    Join Date
    Jul 2006
    Location
    N. Highlands, California, USA
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copy a cell and not a table? (Word 2003)

    Good morning,

    I made sure the auto text was attached to the document and then protected the document and saved it as a template. When I open the template and run the macro I get an error message that the auto text cannot be found. I unprotect the template and manually add in the macro and then reprotect the document. But when I go to resave the template I have to rename it and the auto text/macro does not follow.

    <img src=/S/doh.gif border=0 alt=doh width=15 height=15>

    Warm Regards,

    Summer

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

    Re: Copy a cell and not a table? (Word 2003)

    You cannot save AutoText in a document. So you must save as a template first and then add the AutoText entry.

Posting Permissions

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