Select from a variety of word templates which filepath to open

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jollycobra
    New Member
    • Jun 2014
    • 1

    Select from a variety of word templates which filepath to open

    I would like to use a file path with a variable in it.

    Code:
    Dim rs as recordSet
    Dim Path as String
    Dim ReportName As String
    
    Set ReportName = me.txtreportName 'a textbox on a form to which the code is attached.
     
    Path = ""C:\Users\MyUserName\Documents\Custom Office Templates\"ReportName".docx""
    Please help. I've been at this for some time and nothing is working. Thanks
    Last edited by Rabbit; Jun 13 '14, 05:33 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3662

    #2
    jollycobra,

    Welcome to Bytes!

    This should be the proper syntax:

    Code:
    Dim rs as recordSet
    Dim Path as String
    Dim ReportName As String
    
    ReportName = me.txtreportName 'a textbox on a form to which the code is attached.
    
    Path = "C:\Users\MyUserName\Documents\Custom Office Templates\" & ReportName & ".docx"
    Then, there are a variety of ways to open that file.

    Comment

    Working...