Word 2007 Macro Problem

C

Colin Halliday

I have a Word 2003 fax coversheet template that works fine when creating a
new document in Word 2003, but causes an error when creating a doc from it
in Word 2007.

The user tabs to a text box called "From" and it runs the following code:

If ActiveDocument.FormFields("From").Result = "" Then
With ActiveDocument.FormFields("From")
With .TextInput
.EditType Type:=wdRegularText, Default:=Application.UserName
.Width = 0
End With
End With
End If

It crashes on the .EditType line where it attempts to fillin the user's name
from the username setting inside of Word.

The error is 5224 "This is nat a valid selection".

I have set Macro Security to "Enable all macros" and "trust access to the
VBA project object model".
I have added the Workgroup Templates folder location to the Trusted
Locations list. I have ticked the "Allow Trusted Locations on my network"
check box.

Thanks for any assistance.
 
D

Doug Robbins - Word MVP

I think that all you need is

If ActiveDocument.FormFields("From").Result = "" Then
ActiveDocument.FormFields("From").Result = Application.UserName
End If


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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