By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,607 Members | 1,925 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,607 IT Pros & Developers. It's quick & easy.

Select from a variety of word templates which filepath to open

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

Expand|Select|Wrap|Line Numbers
  1. Dim rs as recordSet
  2. Dim Path as String
  3. Dim ReportName As String
  4.  
  5. Set ReportName = me.txtreportName 'a textbox on a form to which the code is attached.
  6.  
  7. 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
Jun 13 '14 #1
Share this Question
Share on Google+
1 Reply


twinnyfo
Expert Mod 2.5K+
P: 3,483
jollycobra,

Welcome to Bytes!

This should be the proper syntax:

Expand|Select|Wrap|Line Numbers
  1. Dim rs as recordSet
  2. Dim Path as String
  3. Dim ReportName As String
  4.  
  5. ReportName = me.txtreportName 'a textbox on a form to which the code is attached.
  6.  
  7. Path = "C:\Users\MyUserName\Documents\Custom Office Templates\" & ReportName & ".docx"
Then, there are a variety of ways to open that file.
Jun 13 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.