Results 1 to 14 of 14
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Oklahoma, Oklahoma, USA
    Posts
    134
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Discern Win98 from Win2000 (Word 2000 SR1a)

    I have written a macro that records the steps of going into the Style Gallery and selecting a template to update the styles of the current document. However, after recording it, I see that it has hard coded the file path of the template so that it only runs on a Win98 machine and fails on the Win2000 machines since the pathing for templates is totally different. How do I write intelligent code so that the macro will run on either OS and can determine which path to go to for the template?

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

    Re: Discern Win98 from Win2000 (Word 2000 SR1a)

    Either pull the "UserTemplate" or "WorkgroupTemplate" location out of the registry (see below) or, if this is network situation, hard code a custom location.

    Mind you, my production environment is still Word97 (soon to be 2002), so this is an assumption (but I bet it's reliable):

    (Change 8.0 to 9.0)

    UserTemplate reg key:
    HKEY_CURRENT_USERSoftwareMicrosoftOffice8.0CommonF ileNewLocalTemplates

    The WorkgroupTemplate key:
    HKEY_CURRENT_USERSoftwareMicrosoftOffice8.0CommonF ileNewSharedTemplates
    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>

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Discern Win98 from Win2000 (Word 2000 SR1a)

    Kevin,

    Having Word97 and Word 2000 installed I can find the Registry key for 8.0 as you suggest, but no such key exists for 9.0 (Word 2000).

    Would <pre>path = Options.DefaultFilePath(Path:=wdUserTemplatesPath) </pre>

    be of any use ?

    Andrew C

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

    Re: Discern Win98 from Win2000 (Word 2000 SR1a)

    Andrew,

    This is pretty bizarre. I have Office 97 apps installed except Outook. In the Outlook category we installed Outlook 2000. Therefore, my registry is set up for Office 2000 products (populated fully only for Outlook). However, the 9.0 folder structure is there.

    Do you have Outlook 2000 installed? Maybe that's the difference. If so, then these reg keys are not reliable.

    The Word options path you suggest seems to work fine no matter the version. Dorothy didn't need to leave Kansas after all...
    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>

  5. #5
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Discern Win98 from Win2000 (Word 2000 SR1a)

    Kevin,

    Pretty bizarre indeed. I do have outlook 2000 installed. There is no HKEY_CURRENT_USERSoftwareMicrosoftOffice9.0CommonF ileNew key on my system though there is a HKEY_CURRENT_USERSoftwareMicrosoftOffice8.0CommonF ileNew, so it seems these keys are not very reliable.

    When I execute Options.DefaultFilePath(Path:=wdWorkgroupTemplates Path), it returns c:windowsapplication datamicrosofttemplates, and I can find a corresponding entry in the registry at :

    HKEY_CURRENT_USERSoftwareMicrosoftOffice9.0CommonO pen FindPlacesUserDefinedPlacesPlace2

    Actually my userDefined spaces run from 1 to 10, so there.

    BTW there is also a word constant wdWorkgroupTemplatesPath, which may or may not be relevant.

    Strange about the reg keys though. I wonder what others will find.

    Andrew

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Discern Win98 from Win2000 (Word 2000 SR1a)

    The registry keys for Office 2000 are *not* the same as they were for Office 97, as you've discovered. I suspect you will either have to determine which office version you're running and look in the appropriate locations or you need to use an alternate approach using built-in constants.
    Charlotte

  7. #7
    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: Discern Win98 from Win2000 (Word 2000 SR1a)

    Mine are here in 2000:

    HKEY_CURRENT_USERSoftwareMicrosoftOffice9.0CommonG eneral

    UserTemplates string
    SharedTemplates string (Workgroup templates path)

    I agree that Word's internal functions are probably the most reliable in this case:

    str1 = Options.DefaultFilePath(wdUserTemplatesPath)
    str2 = Options.DefaultFilePath(wdWorkgroupTemplatesPath)

  8. #8
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Oklahoma, Oklahoma, USA
    Posts
    134
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Discern Win98 from Win2000 (Word 2000 SR1a)

    I've read everything that was posted here but had no understanding as to how I was supposed to benefit from the information. Forgive me my shortcomings and limitations.

    Here's the code I've been attempting to use; however, I don't know how to tie the default path onto the remainder of the path and template name.

    temp = Options.DefaultFilePath (wdUserTemplatesPath)
    ActiveDocument.CopyStylesFromTemplate Template = temp firm smartool.dot

    I get an error on the second line because of the way I'm trying to append the "firmsmartool.dot" to the default path. Help.

  9. #9
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Discern Win98 from Win2000 (Word 2000 SR1a)

    Something like this?

    ActiveDocument.CopyStylesFromTemplate Template = temp & "" & firm & "smartool.dot"
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  10. #10
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Oklahoma, Oklahoma, USA
    Posts
    134
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Discern Win98 from Win2000 (Word 2000 SR1a)

    Just tried your suggested code and I still get a debug error <img src=/S/sad.gif border=0 alt=sad width=15 height=15>

  11. #11
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Discern Win98 from Win2000 (Word 2000 SR1a)

    Sorry.
    A. I forgot a backslash
    B. Syntax for Copy StylesFromTemplate was incorrect- I should have checked that.

    Try:
    ActiveDocument.CopyStylesFromTemplate (temp & "" & firm & "smartool.dot")

    Assuming that vars temp and firm exist, and the resulting path is valid.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  12. #12
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Discern Win98 from Win2000 (Word 2000 SR1a)

    There is no reason to use the registry keys for this purpose.

    The Options.DefaultFilePath thingee does the deed.

  13. #13
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Discern Win98 from Win2000 (Word 2000 SR1a)

    THat code will not run on a Macintosh.

    It's best to get in the habit of using
    Application.PathSeparator

  14. #14
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Discern Win98 from Win2000 (Word 2000 SR1a)

    Yes I am aware of that as posted <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Cat=&Board=vb&Number=70984&page=0& view=expanded&sb=5&o=0&vc=1#Post70984>here</A>. My excursion into the registry was in response to a post from Kevin, and not a suggested solution.

    Andrew

Posting Permissions

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