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

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Generate a new doc from a dot on the web (Word 97/SR2)

    • This topic has 5 replies, 4 voices, and was last updated 23 years ago.
    Author
    Topic
    #369184

    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.

    Viewing 1 reply thread
    Author
    Replies
    • #580664

      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

    • #580667

      Edited by jscher2000 on 04-Apr-02 23:58.

      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).

      Test Script to Open Word Doc
      
      Sub MakeNew(strTemplate)
      On Error Resume Next
      Dim oshell
      Set oshell = CreateObject("Wscript.Shell")
      ' 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
      
      
      
      

      This is a test.

      To create a new document based on test.dot, click here.

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

      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

      Hope this helps a bit.

      • #580872

        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!).

        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

        • #580881

          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. grin (The lastest actually is the box set of the first season of The Simpsons.)

          • #580886

            Speaking of the Simpsons, a big ‘Doh’ for me! – I use the ‘hold Shift while create new’ method constantly when testing templates. doh
            (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….)

    Viewing 1 reply thread
    Reply To: Generate a new doc from a dot on the web (Word 97/SR2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: