Consulting

Results 1 to 4 of 4

Thread: new doc from template from excel

  1. #1
    VBAX Newbie
    Joined
    Jan 2018
    Location
    La Rochelle
    Posts
    2
    Location

    new doc from template from excel

    Hello,

    I'd like with Excel create a new doc in word from a template.

    Dim appWD As Word.Application
    Dim docWD As Word.Document
    
    On Error Resume Next
        Set appWD = GetObject(, "Word.application")    'gives error 429 if Word is not open
        If Err = 429 Then
            Set appWD = CreateObject("Word.application")    'creates a Word application
            Err.Clear
        End If
    Documents.Add Template = "Macintosh HD/users/eric/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Templates.localized/CONV_INTRA_2015.dotx", NewTemplate:=False, DocumentType:=wdNewBlankDocument, Visible:=True
    The result is a new doc with the template normal.

    Someone to help me please ?

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Try:
    Dim appWD As New Word.Application
    Dim docWD As Word.Document
    Set docWD = appWD.Documents.Add(Template:="Macintosh HD/users/eric/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Templates.localized/CONV_INTRA_2015.dotx", _
      NewTemplate:=False, DocumentType:=wdNewBlankDocument, Visible:=True)
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    VBAX Newbie
    Joined
    Jan 2018
    Location
    La Rochelle
    Posts
    2
    Location
    Hi,

    Thanks for your answer. That's don't works. I'll try to do by a different way.

    Quote Originally Posted by macropod View Post
    Try:
    Dim appWD As New Word.Application
    Dim docWD As Word.Document
    Set docWD = appWD.Documents.Add(Template:="Macintosh HD/users/eric/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Templates.localized/CONV_INTRA_2015.dotx", _
      NewTemplate:=False, DocumentType:=wdNewBlankDocument, Visible:=True)

  4. #4
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Quote Originally Posted by Ric View Post
    That's don't works. I'll try to do by a different way.
    In that case I suggest you check your file path & name.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

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