[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

Word 2010 Macro Question

How do I make this code generic for all users in my office?

Application.Templates( _
        "C:\Users\chayden\AppData\Roaming\Microsoft\Document Building Blocks\1033\14\Built-In Building Blocks.dotx" _
        ).BuildingBlockEntries("Grid").Insert Where:=Selection.Range, RichText:= _

I would hate to have to replace "C:\Users\chayden" for all of my users.

thanks!
0
cchayden
Asked:
cchayden
  • 3
1 Solution
 
ItpotterCommented:
Use application(exe) relative path

System.Windows.Forms.Application.StartupPath
or
string currentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
0
 
cchaydenAuthor Commented:
Well I have messed with this a little while and didn't get it. I am wondering if you could type out the line for me please. (I just cut and paste the original line from the record macro code so I don't really know all that much about VBA)

Thanks!
0
 
cchaydenAuthor Commented:
I guess I should close this.

I finally ended up with this working code.

Application.Templates( _
        Environ("APPDATA") & "\Microsoft\Document Building Blocks\1033\14\Built-In Building Blocks.dotx" _
        ).BuildingBlockEntries("Grid").Insert Where:=Selection.Range, _
        RichText:=True
0
 
cchaydenAuthor Commented:
=)
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now