Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Mar 2001
    Location
    St Georges du Bois, Pays de la Loire
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Generate a new doc from a dot on the web (Word 97/SR2)

    I want to generate a new document (in Word operating within the browser) from a .dot that is held on a server (on our intranet). However whenever I use an html link to the dot the dot itself opens instead of generating a new document.

    Is there any way to force the dot to generate a new doc using an htm link?

    What I eventually want to do is to have the dot generate a unique serial number onto the new doc.

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

    Re: Generate a new doc from a dot on the web (Word 97/SR2)

    This probably means that the default action for .dot files is set to Open instead of New.

    To check this:

    Open Windows Explorer
    Select View/Folder Options...
    Click the File Types tab
    Scroll to Microsoft Word Template and select this
    Click Edit...

    You should see a list of actions such as Print, Open and New. The default action is bold.
    If Open is currently the default action and you want it to be New, select New and then click on Set Default.
    Click OK until you are back in Windows Explorer.

    HTH, Hans

  3. #3
    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: Generate a new doc from a dot on the web (Word 97/SR2)

    <P ID="edit" class=small>Edited by jscher2000 on 04-Apr-02 23:58.</P>On the issue of getting from an opened template to a document, try this Lounge classic:

    Re: Workgroup Templates, 13-Feb-01, by KarenWright

    Another way would be to use JavaScript or VBScript to create the new document. The following works if you allow scripting of ActiveX objects not marked safe for scripting in the Intranet zone (if you set to Prompt, the red line generates the attached dialog).

    Unfortunately, however, this approach creates a new instance of the Word application. It would be very, very nice for intranet developers if one could do this:

    Dim wrdApp
    Set wrdApp = GetObject(, "Word.Application")
    wrdApp.Documents.Add template.dot

    but for security reasons, this cannot be done from inside a web page, even in the Intranet zone. (See PRB: Cannot Call GetObject from Script in IE to Access Running Object (Q239470).

    <pre><html><head><title>Test Script to Open Word Doc</title>
    <script language="vbscript">
    Sub MakeNew(strTemplate)
    On Error Resume Next
    Dim oshell
    <font color=red>Set oshell = CreateObject("Wscript.Shell")</font color=red>
    ' If "winword.exe /ttemplate.dot" doesn't work, you can try Plan B, which
    ' is to shell the template name and add the below AutoOpen macro to the template
    oshell.Run "winword.exe /t" & strtemplate
    Set oshell = Nothing
    End Sub
    </script>
    </head>
    <body>
    <h3>This is a test.</h3>
    <! -- The comment tags are broken to allow posting in the lounge -- >
    <! -- Trying to open a URL will fail to run the code; you need to pass a UNC. -- >


    To create a new document based on test.dot,
    <SPAN onClick=MakeNew("serversharefoldertest.dot")
    STYLE="font-weight: bold;cursor: hand;">click here</SPAN>.</p>
    </body></html></pre>


    As noted above, if you cannot use the /t method, you can embed the following macro in test.dot:

    <pre>Sub AutoOpen()
    Dim aDoc As Document, aTemp As Template, docNew As Document
    Set aDoc = ActiveDocument
    Set aTemp = aDoc.AttachedTemplate
    If (aTemp.Path & Application.PathSeparator & aTemp.Name) = _
    aDoc.FullName Then
    'This "document" is a template
    If MsgBox("Create a new document based on this template?", _
    vbQuestion + vbYesNo) = vbYes Then
    'Create a new document
    Set docNew = Documents.Add(Template:=aDoc.FullName, NewTemplate:=False)
    Else
    'Just close yourself
    End If
    aDoc.Close SaveChanges:=wdDoNotSaveChanges
    Else
    'Things you want to happen if this is a doc based on the template
    End If
    Set aTemp = Nothing
    Set aDoc = Nothing
    If Not docNew Is Nothing Then
    docNew.Activate
    Set docNew = Nothing
    End If
    End Sub</pre>

    Hope this helps a bit.
    Attached Images Attached Images

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Generate a new doc from a dot on the web (Word 97/SR2)

    Jefferson,

    I went down precisely the paths you are describing, a couple of years ago (only difference my code was a lot cruder than yours!<g>).

    One warning that must be attached to the AutoOpen approach: you can never again directly open and edit that template! - you can get to the code in the template, by creating a new document based on the template and then editing the template's code from there, but every time you ever need to make any change at all to the template in Word, you need to go through some contortions: create a new document based on the template, save that as a new template, copy the code from the original template and put that into the new template, and cetera.

    Gary

  5. #5
    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: Generate a new doc from a dot on the web (Word 97/SR2)

    I'm not sure this is documented anywhere, but if you hold the Shift key continuously until the template loads fully the AutoOpen macro will not run. Sort of like what I have to do when I need to work with a CD briefly, and then put the latest movie back in my DVD drive. <img src=/S/grin.gif border=0 alt=grin width=15 height=15> (The lastest actually is the box set of the first season of The Simpsons.)

  6. #6
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Generate a new doc from a dot on the web (Word 97/SR2)

    Speaking of the Simpsons, a big 'Doh' for me! - I use the 'hold Shift while create new' method constantly when testing templates. <img src=/S/doh.gif border=0 alt=doh width=15 height=15>
    (our templates tend to have a slew of code in Document_New; if we want to test/step through the code the best method is to create a new document while holding down Shift, then from the new document go to the template's ThisDocument/Document_New and start stepping....)

Posting Permissions

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