S
src
I've got the strangest problem going on right now in Word 2002. I'm
trying to set the User Templates Path with VBA.
I call a function that gets the UserName. I then insert it into a
string and use that to set the path. Here's a bit of the code:
Options.DefaultFilePath(Path:=wdWorkgroupTemplatesPath) = "V:\Reference
\Templates\"
Options.DefaultFilePath(Path:=wdStartupPath) = "C:\Documents and
Settings\" & GetUserName _
& "\Application Data\Microsoft\Word\STARTUP\"
Options.DefaultFilePath(Path:=wdUserTemplatesPath) = "C:\Documents and
Settings\" _
& GetUserName & "\Application Data\Microsoft\Templates\"
I can successfully run this once. But the next time I run it, I get:
Run-time Error '4101'
Illegal Function Call
on the 3rd line, wdUserTemplatesPath.
I've truncated the string to
Options.DefaultFilePath(Path:=wdUserTemplatesPath) = "C:\Documents and
Settings\" _
& GetUserName & "\Application Data\Microsoft\"
and it works perfectly every time. As soon as I add "Templates\" to
the line, it crashes after the first run.
In Word 2003, this isn't a problem, and both of the other strings
(WorkgroupTemplatesPath and StartupPath) don't have this problem.
I've tried adding "Application." to the Options to no avail, and I've
left the trailing slash off with no effect.
Anyone see this before? Thanks!
trying to set the User Templates Path with VBA.
I call a function that gets the UserName. I then insert it into a
string and use that to set the path. Here's a bit of the code:
Options.DefaultFilePath(Path:=wdWorkgroupTemplatesPath) = "V:\Reference
\Templates\"
Options.DefaultFilePath(Path:=wdStartupPath) = "C:\Documents and
Settings\" & GetUserName _
& "\Application Data\Microsoft\Word\STARTUP\"
Options.DefaultFilePath(Path:=wdUserTemplatesPath) = "C:\Documents and
Settings\" _
& GetUserName & "\Application Data\Microsoft\Templates\"
I can successfully run this once. But the next time I run it, I get:
Run-time Error '4101'
Illegal Function Call
on the 3rd line, wdUserTemplatesPath.
I've truncated the string to
Options.DefaultFilePath(Path:=wdUserTemplatesPath) = "C:\Documents and
Settings\" _
& GetUserName & "\Application Data\Microsoft\"
and it works perfectly every time. As soon as I add "Templates\" to
the line, it crashes after the first run.
In Word 2003, this isn't a problem, and both of the other strings
(WorkgroupTemplatesPath and StartupPath) don't have this problem.
I've tried adding "Application." to the Options to no avail, and I've
left the trailing slash off with no effect.
Anyone see this before? Thanks!