Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    AutoText in Document (2002)

    I was under the impression that Word 2002 allowed the storing of AutoText
    in documents (as wll as in the attached template), but I can't see how to do this.

    Can it be done? I need "portable" autotext -- available even when the template
    is not.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  2. #2
    5 Star Lounger
    Join Date
    Dec 2000
    Location
    Tallahassee, Florida, USA
    Posts
    901
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoText in Document (2002)

    I don't believe so, Kevin. The closest that I could think of accomplishing what you want is to create a macro in the document which would be portable... assuming the recipient enables the macros or runs on low security... <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Karen

  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoText in Document (2002)

    Karen, thanks for the reply. That's very strange. I thought for sure
    I read that somewhere. Oh well. What I am trying to do is store
    formatted text in a document variable --that is, hidden from the
    user, but accessible programmatically so as to insert it at various
    places in the document.

    Currently I store the formatted text in autotext in a user's Normal.dot (I once said
    I'd never do this, but I can think of no other way). If that user sends the document to
    another user, the formatted autotext is not available.. Maybe it's possible to now store
    formatted text in document variables. I doubt it.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  4. #4
    New Lounger
    Join Date
    Feb 2003
    Location
    London, Gtr London
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoText in Document (2002)

    >> Maybe it's possible to now store formatted text in document variables. I doubt it. <<

    I have an idea for you. I agree it's really bad to put this special AutoText into Normal.dot.

    Couldn't you write a Rich2Tags "parser" which would pass through the formatted text looking at a limited number of things:
    - Font size
    - Italics, Bold, Underlined
    - Line breaks
    - Tabs (hmm... ASCII 9 characters are no problem, but tab settings could be rough)
    And then convert the formatted text into a kind of "tagged" plain text which could be put into the document variables.

    In other words, why not store this in the document variable:
    I'm <Bold>Kevin</Bold><break>I live in <Italic>Hollywood</Italic>.<break>

    Then when it's time to access the formatted text programmatically, you have a Tags2Rich parser routine, which goes through and reconstitutes the tags back into Rich text.

    I'm Kevin
    I live in Hollywood.

    For most purposes, your Rich2Tags and Tags2Rich routines wouldn't have to support all that many kinds of formatting beyond the basics.

    The funny thing is, I'm doing the exact same kind of centralized document automation project that you're working on (you mentioned it in a post in November), to eliminate most templates and instead have few templates with an intelligent DLL or COM Add-In do all the work. When I saw your November post just now, I got all excited and I was just in the process of going through and reading all your posts! After I've read all your posts, I'm going to want to ask you a few things. (I'll put those in another post)

    I just have to make a bad pun: When you actually insert the text (above) into Word, it's a kind of Tags to Riches story, ain't it? <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  5. #5
    New Lounger
    Join Date
    Feb 2003
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoText in Document (2002)

    My approach is to create a library of autotext in a global addin template (or series of templates). These can be centrally stored which means there is only one point of maintenance. Of course all users have to have these global addins loaded in order to use the autotext. Its not a perfect solution but better than using Normal.dot.

    If interested look at Autotext Manager in www.cdev.co.uk

    Chris

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoText in Document (2002)

    Chris,
    The difference here is that the autotext I'm creating is dynamic not static, so storing them
    in a global would not work.

    The cdev site is great. And their AutoText Manager is a fine product. I never had the spare
    time, but that's what I wanted to write for years.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  7. #7
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoText in Document (2002)

    Geoff,
    Great to hear from you. I like the way you think. Hummm. That is a great idea.

    Let me see if I can get my brain around that one.

    I see one immediate problem with your idea: How do you
    produce that rich text without a document or richtext control? If Word were "tag-based",
    like WordPerfect I can see it quite easily. But Word needs some container for rich text
    and that means a document or richtext control - visual controls -- what we need is
    a non-visual control. MS, are you listening???

    I do admit that there may be such a thing floating around that will work, but I'm not
    aware of it.

    How about letting Word decifer html tags in order to produce the rich text?

    Office 11 will do that nicely with XML, but Office 10? I don't know. I'll have to test.

    As for your future posts: post away!

    p.s. I only live in Hollywood when I'm filming...all other times I live in Hollyword. (Hey one bad pun
    deserves another.)
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  8. #8
    New Lounger
    Join Date
    Feb 2003
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoText in Document (2002)

    Kevin, Geoff

    It is a good idea to store the formatted text in a Doc Var as tagged text.

    I have produced a macro to store formatted text in a database as html tagged asci text and this is a similar issue, I used Word's own 'convert to htm' to do the job, as Kevin has mentioned. Doing it in RTF sounds harder.

    The main problem is that formatting is not particularly well preserved.

    You could always send the document out as a template masquerading as a document. Ouch!

    Chris

  9. #9
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoText in Document (2002)

    Chris,
    That sounds pretty good. Care to share your code? I'd love to see
    how you use "convert to htm". As Goeff seemed to know, my formatting
    needs are rather limited: just some underlining and occassional bolding.

    So, if you've got some kind of parser/converter, you might just be the lucky winner!
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  10. #10
    New Lounger
    Join Date
    Feb 2003
    Location
    London, Gtr London
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoText in Document (2002)

    >> How do you produce that rich text without a document or richtext control? <<

    But we do have a document, don't we? Your initial quest was "to store Rich text in a document variable," right? So presumably there is the document you're taking that value from.

    I think the Tags2Rich parser would take the plain ASCII value stored in the document variable and recreate the Rich Text within the Active Document using Selection.TypeText right there in place within the document.


    OTOH, if your preference is to create a new AutoText entry dynamically, and not necessarily insert the Rich Text into the Active Document, I have another idea. Perhaps you want to let your user insert that AutoText when and where and if she pleases.

    Here's my other idea...

    Turn ScreenUpdating off, and Add a document. Do all your dirty work (uh, I mean, create the Rich Text!), and then SelectAll, and create the AutoText entry, and then Close the ActiveDocument.

    <font face="Georgia">' Take care of the user interface needs ---------------------------------------
    System.Cursor = wdCursorWait 'Set the hourglass cursor
    Application.ScreenUpdating = False 'Turn screen updating OFF
    StatusBar = "Generating Dynamic Autotext..." 'Might be nice to fill in the status bar
    ' Prepare environment and remember setting -------------------------------
    Documents.Add 'Ensure we have a clean document
    bDidFCShow = ActiveWindow.View.ShowFieldCodes 'Remember users field code option
    Selection.Collapse 'Ensure there is no selection
    ActiveWindow.View.ShowFieldCodes = False 'So we do not see field codes
    ' Get to work creating required Rich Text --------------------------------------
    ' ....
    Selection.TypeText "Do dirty work of Tags2Rich!"
    Selection.TypeText "Step thru ASCII text from Document Variable, etc...."
    ' ....
    ' Make the AutoText entry ------------------------------------------------------------
    Selection.WholeStory
    NormalTemplate.AutoTextEntries.Add Name:="DynamicAutoTextOfMine", Range:= Selection.Range
    ' Clean up --------------------------------------------------------------------------------
    ActiveWindow.View.ShowFieldCodes = bDidFCShow 'Restore user's field codes option
    ActiveDocument.Close savechanges:=wdDoNotSaveChanges 'Get rid of temporary doc
    ' Take care of user interface again ---------------------------------------------------------------------
    System.Cursor = wdCursorNormal 'Set a normal cursor
    Application.ScreenUpdating = True 'Turn screen updating ON
    StatusBar = "" 'clear the status bar</font face=georgia>

    Is that what you meant?

  11. #11
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoText in Document (2002)

    This is pretty much the way I am doing it now. But i don't like it.

    Pasting in text at the IP or creating a hidden document, then formatting
    the text using all manner of parsing techniques to find the text that
    needs the formatting, etc, etc. then storing that in autotext in the user's
    normal.dot is not my idea of a good time.

    Your idea of tagged text in a doc var is champion. But getting the text from
    tagged docvar values to document formatted text -- that's the sticky wicket.

    My hope is that pasted XML will "convert" to formatted text in Office 11.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  12. #12
    New Lounger
    Join Date
    Feb 2003
    Location
    London, Gtr London
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoText in Document (2002)

    >> using all manner of parsing techniques to find the text that needs the formatting, etc, etc. then storing that in autotext in the user's normal.dot is not my idea of a good time. <<

    Fair enough; although it might be easier than you think. It would be basically a linear process. That is, you could process the tagged text in a serial manner, doing Selection.TypeText actions as each tag is encountered. It's probably not that bad.

    If you're not convinced, then another possibility would be to store the Rich Text in the DocVar in RTF format (gee, that's what RT stands for!).

    >> But getting the text from tagged docvar values to document formatted text -- that's the sticky wicket. <<

    Following up on the other possibility (DocVar value is in RTF format)...

    When you want to create the actual AutoText entry (you should turn off ScreenUpdating, etc. as before), here's what I envision...
    1. grab the RTF from the DocVar and put it into a string sTEXTFROMDOCVAR
    2. write the contents of the DocVar to a file using plain ole BASIC sequential file statements
    Open "c:temp.rtf" For Output As #1
    Print #1, sTEXTFROMDOCVAR
    Close #1
    3. open the "temp.rtf" file using Word's FileOpen command
    4. Select the WholeStory
    5. create the AutoText in the NormalTemplate
    6. close "temp.rtf" file
    7. delete "temp.rtf" file

    Two additional thoughts:

    A. If you took this approach, you might not want to write the "temp.rtf" to "c:" in a hardcoded manner like I showed. It would be better to grab the user's Personal or Temp directory from the Registry "ShellFolders" or using the API and write it there. A person may not have rights to "c:", say if they were working on a Terminal Server.

    B. You might be able to avoid creating a "temp.rft" file all together if you muck around with DataObject or the Clipboard and get MS Word to recognize the RTF string as the correct Rich Text datatype.

  13. #13
    New Lounger
    Join Date
    Feb 2003
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoText in Document (2002)

    >That sounds pretty good. Care to share your code? I'd love to see
    >how you use "convert to htm".

    I'll see if I can package something up over the weekend and get is back here for next week.

    Chris

  14. #14
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoText in Document (2002)

    Capital!
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  15. #15
    New Lounger
    Join Date
    Feb 2003
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoText in Document (2002)

    A bit late... but here is the DocAutotext method. (Word 2000 tested.)

    Open the document DocAutotext.doc.

    Select some text and press the SetAutotext button, give it a name eg fred.

    Go to the end of the document and press Insert Autotext, named fred or whatever.

    Let me know how it goes for you.

    Chris (chris@cdev.co.uk)
    Attached Files Attached Files

Page 1 of 2 12 LastLast

Posting Permissions

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