Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2006

Tip: Looking for answers? Try searching our database.

Word 2007 Macro Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Colin Halliday - 22 Nov 2006 22:22 GMT
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.

Signature

Colin Halliday

Doug Robbins - Word MVP - 23 Nov 2006 22:27 GMT
I think that all you need is

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

Signature

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

>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
[quoted text clipped - 24 lines]
>
> Thanks for any assistance.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.