Using FileCopy with Word 2007

N

Nairda

Hi

I am updating some macros for customer use within Word 2007. Testing has
proven that the macros work fine with Word versions '97 thru 2003. Part of
the installation process uses FileCopy to copy .dot files to the default
Startup and Template directories;

D:\Documents and Settings\user_ID\Application Data\Microsoft\Word\STARTUP

and

D:\Documents and Settings\user_ID\Application Data\Microsoft\Templates

The problem is that when I run the macro, application control enters the
error handling and generates an error dialog stating that the template file
cannot be created due to issues with write access.

I assume that the security within Word 2007 is designed to prevent malware
from writing macros to these default locations despite these Trusted
Locations being enabled from within the Trust Center.

It would appear that the templates are created in these locations, but the
error message is still generated.

Is this a known issue or is there a workaround that will prevent the error
messages?

Many thanks for any assistance.
 
J

Jay Freedman

Hi Nairda,

The following code works without any problems or messages in Word 2007 on
Windows XP:

Sub x()
Dim srcPath As String
Dim destPath1 As String
Dim destPath2 As String

srcPath = "E:\temp\"
destPath1 = Environ("appdata") & "\Microsoft\Templates\"
destPath2 = Environ("appdata") & "\Microsoft\Word\Startup\"

FileCopy srcPath & "ATtest.dot", destPath1 & "ATtest.dot"
FileCopy srcPath & "ATtest.dot", destPath2 & "ATtest.dot"
End Sub

Whatever difficulty you're having, it is not due to any "security" or
"application control" within Word 2007, because there isn't any. Designating
a folder as a trusted location determines only whether Word is willing to
run macros from templates found in that location, and has nothing to do with
whether you can copy files into the folder.

I think you'll eventually find that the error message is exactly correct, if
uninformative -- that the particular user running the macro doesn't have
Full Control rights, or at least Write permission, for the folder. Possibly
that profile is damaged in some way. Can you freely copy files into and out
of those folders outside of Word, using Windows Explorer?

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
N

Nairda

Hi Jay

Thank you for your response.

Having followed your advice, I have determined the cause of the problem.
Despite being the developer for these macros, the machines we use have
device/content encryption and this, in turn restricts access to the default
template/startup locations. It's an organisational-wide encryption policy,
so I shall have to develop the macros on an alternative machine.

Many thanks for your time and assistance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top