Results 1 to 13 of 13
  1. #1
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Postitioning text (2000 / 2003)

    Hi,

    Would someone mind guiding me in the right direction for the following.

    I am trying to get certain information to be included into a letter written by secretarys. So far when they click a button for a certain type of letter it will ask them a series of questions using inputboxes and it also collects some information from the file that is open.

    Once all the information is gathered the answers are displayed into the letter. However... I can only get the answers to print in one stright line. I would like to know if its possible to position them around the page I want to pleace each item where I want not together.

    Maybe if someone could just give an example of different commands, that effect the position of items on the document, I can then figure out how to position more than one.

    Many thanks
    Regards
    Gerbil (AKA Kevin)

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

    Re: Postitioning text (2000 / 2003)

    Will most of the text of the letter be fixed, with a limited number of places where user input is needed? If so, consider placing form fields from the Forms toolbar in those places, and protecting the document for forms.

    Otherwise, you could place bookmarks in the document and use those to place the information.

    For yet another approach, see the Word template with startup userform attached to <post:=259,183>post 259,183</post:>.

  3. #3
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Postitioning text (2000 / 2003)

    Thanks Hans

    If they are writting this particular type of letter then I will want the input box items to be in the same place everytime, however I will want some at the top of the page and some at the bottom allowing them to tyoe the body of the letter in the middle.

    I will check out you linked post, thank you.
    I was using bookmarks how would I use them in code to place the inputed items. If there were more than one of these letter throughtout the document, how will it know which bookmark to go to.

    Thank you
    Regards
    Gerbil (AKA Kevin)

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

    Re: Postitioning text (2000 / 2003)

    You can divide the document into several sections by inserting section breaks. When you protect the document for forms, you can specify which sections will be protected and which ones will be left unprotected, so that the user can enter text freely there.

    > If there were more than one of these letter throughtout the document, how will it know which bookmark to go to.

    Because YOU specify the bookmark. I do dearly hope that you know where things should go...

    Example:

    Dim strInput As String
    strInput = InputBox("Enter the company name.")
    ActiveDocument.Bookmarks("Company").Range.Text = strInput

  5. #5
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Postitioning text (2000 / 2003)

    Hans,

    I understand that I set the bookmarks, my question was not that simple.

    Example:

    I have a client, and this client has more than 100 letters in one document over the course of 5 years. The letters are for all different things. But out of the 100 letters there are 5 letters where we have referred them to a collegue. When we do a referral we must include certain information, in a certain way. Because the process is complex I am trying to creat a way that the secretary's will find it easy to understand and use, by using input boxes to get ALL the required infomation. The problem is I need to have the layout in a set format. But if I use a bookmark called COMPANY and I want to use the input box to get that information from the user, there can only be one bookmark called company in the letter, but as I mention above there are already 5 letters like this in the document.

    Unless if I save a template with the bookmarks in an use insert document, but wont the bookmarks get ignored if they are alreay in the document else where.

    Many thanks for your time.
    Regards
    Gerbil (AKA Kevin)

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

    Re: Postitioning text (2000 / 2003)

    You can refer to a bookmark in other places using REF fields - look up REF in the Word help.

    You could also use custom document properties or document variables - see the demo template I pointed you to higher up in this thread.

  7. #7
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Postitioning text (2000 / 2003)

    Hi Hans thanks for the link

    I don't think this will work for my situation. I dont want to duplicate the data from the value from the same bookmark. I Just want the bookmark itself to be in the same place whenaver we write that type of letter.

    For excample lets say the Client A comes and sees StaffA on 01/01/2008 and StaffA wants to referrer Client A to Staff be, we would run the referral macro to generate a referral letter to StaffB from StaffA and include the referral date 01/01/2008 which we get from a inputbox.

    Time goes by and ClientA has had lots of appointments and comes in again to see StaffA again on 08/08/2008 StaffA referrs Client A to Staff C again we generate a referral letter.

    But because the Bookmark "referraldate" is already used higher in the document when we run the marco the new referral date goes next to the old one, not in the new letter.

    As I also need to start tracking these referrals in more detail. I was wondering if you thought the following solution might work to solve the above challenge.

    If I use the macro to ask all the questions, I could use the code you helped me with before to export the answers into a databasetable, then import the answers back from the table to display on my letters. They would always have the same format because it imports as a table.

    My question aside from will it work, is this.

    Is it possible to maniplate the imported table (by code not manual) to look a little better.

    Thank you Hans
    Regards
    Gerbil (AKA Kevin)

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

    Re: Postitioning text (2000 / 2003)

    The InsertDatabase method has arguments for formatting the table - see the help for this method. But if you want to refer to values from an Access table in locations scattered through the document, InsertDatabase is probably not the ideal way to do it. It might be better to open a DAO or ADO recordset, loop through its records and read the fields as needed.
    But I cannot really help you with your general question - it's getting beyond the scope of Woody's Lounge in my opinion.

  9. #9
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Postitioning text (2000 / 2003)

    How about using the DOCPROPERTY field in your boilerplate text? Since you are inserting the information into the document anyway, presumably there is not a privacy reason not to use the field.

    Or, you could always fall back on the old fashioned method that predated fancy bookmarks: text placeholders like **COMPANY** and **ACCOUNTBALANCE**.

  10. #10
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Postitioning text (2000 / 2003)

    Hi thanks for the reply,

    Doesn't DOCPROPERTY only allow me to call the valuse of those fields in the properties of the document. I need to asign values from the input boxes.

    I am interest in how predated fancy bookmarks works. do you meanwithin a template I could type words like ***CRRRRRRRRRN*** and then place the words with the inputbox values. Then of course when the template is inserted again those old bookmarkswould have been replaced and therefore the inputboxes value would update the new template again.

    thanks
    Regards
    Gerbil (AKA Kevin)

  11. #11
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Postitioning text (2000 / 2003)

    Hi,

    I got it! Your idea of using ***COMPANY*** is what done it. I have no idea what you meant by it but it made me think of using Find and replace to change items withing the document, and of course once changed the next time I need to type a simular letter in the same document the previous keywords have already changed so it wont change the original one.

    Many thanks

    Heres what I used

    Selection.Find.ClearFormatting
    With Selection.Find
    .Text = "{***DEPT***}"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = True
    .MatchWholeWord = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Selection.Text = strRSpec
    Regards
    Gerbil (AKA Kevin)

  12. #12
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Postitioning text (2000 / 2003)

    You got it exactly.

    Recorded Find/Replace code often involves numerous repetitions of the same settings. You can streamline that for slightly better performance and lower weight once you have it working the way you want.

  13. #13
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Postitioning text (2000 / 2003)

    Thanks for your help.

    My finished code is now

    ' Find and replace the keywords for F2 Form
    i = i + 1
    Do While Not i = 27
    Selection.Find.ClearFormatting
    With Selection.Find
    .Text = strFind(i)
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = True
    .MatchWholeWord = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Selection.Text = strReplace(i)
    i = i + 1
    Loop
    Selection.Find.ClearFormatting
    With Selection.Find
    .Text = "[TYPE YOUR LETTER HERE]"
    End With
    Selection.Find.Execute

    There 26 items to replace so I decided on using an array. Works well once again thanks you and Hans certainly pointed me in the right direction.
    Regards
    Gerbil (AKA Kevin)

Posting Permissions

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