Naming a formfield

I am using Word 2003, I have added a formfield with code as shown below, 
declared the ffield as a formfield but the code is debugging with object 
variable not set for some reason on the '.Name'.  I have successfully used 
this bit of code in other templates I have created.  Can anyone offer me an 
alternative or solution please?

        Set ffield = _
        ActiveDocument.FormFields.Add(Range:=Selection.Range, _
        Type:=wdFieldFormTextInput)
        
        With ffield
            
            .Name = "contaminant"
            
            With .TextInput
                
                .Default = "Enter details"
            
            End With
        
        End With



Thanks


-- 
Mark
0
Utf
2/2/2010 5:32:01 PM
word.vba.general 1023 articles. 1 followers. Follow

1 Replies
1521 Views

Similar Articles

[PageSpeed] 54

See http://word.mvps.org/FAQs/MacrosVBA/AssignNameToFmFld.htm

-- 
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so 
all may benefit.

Mark wrote:
> I am using Word 2003, I have added a formfield with code as shown
> below, declared the ffield as a formfield but the code is debugging
> with object variable not set for some reason on the '.Name'.  I have
> successfully used this bit of code in other templates I have created.
> Can anyone offer me an alternative or solution please?
>
>        Set ffield = _
>        ActiveDocument.FormFields.Add(Range:=Selection.Range, _
>        Type:=wdFieldFormTextInput)
>
>        With ffield
>
>            .Name = "contaminant"
>
>            With .TextInput
>
>                .Default = "Enter details"
>
>            End With
>
>        End With
>
>
>
> Thanks 


0
Jay
2/2/2010 5:33:36 PM
Reply:

Similar Artilces:

Count File Names
Hi All, I having an issue with version control on Buisness cases. I currently have a spreadsheet that looks into a folder and picks up details from a number of files. However, they require version control numbers so there will eventually be multiple files say 2010-01 v1.0, 2010-01 v1.1. Is there a way I can: 1) Get a macro to count the number of 2010-01 files there are in the folder, and 2) Get my version control sheet to look at the latest version of the file (in this example: 2010-01 v1.1) Cheers, Chris See if this code works. I assume that 2010-01 is year and month. ...

M2004: Change name on home page?
I'm using Money 2004. On the home page it says "So-and-so's Money Home Page". How can I change the name that appears there? -Rod > I'm using Money 2004. On the home page it says "So-and-so's Money Home > Page". How can I change the name that appears there? Figures... I always seem to find a solution right after posting a question! Click Accounts & Bills, Account Setup, Update Personal Information. -Rod ...

Name prefixing in reply message
All, I'm not even sure what terms to google for related to this problem. If you get an email from someone in the Office XP version of Outlook, and you click reply to that email, then start typing inside the portion of the message that contains the original message you replied to, it will automatically prefix everything you write with your name. How does one turn this off? Thanks in advance! TwistedPair wrote: > I'm not even sure what terms to google for related to this problem. If you > get an email from someone in the Office XP version of Outlook, > and you click...

Comparing first and last names in two lists #2
I have two data sources that each contain about 8000 names in seperate fields for first and last name. I can put them on seperate worksheets or append one to the other. I need to make them match and find out where they don't. Messed with consolidate but not sure if that will work for more than one column at a time. FYI data set one is from a school transportation database and data set two is from the main student database from the same school district. ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages dir...

File name from a cell
I am trying to have date in a cell become the file name and appear i the save as dialog box as the file is saved the first time -- Message posted from http://www.ExcelForum.com One way: Option Explicit Sub testme01() Dim mySuggestedFileName As String Dim myFileName As Variant With Worksheets("sheet1") mySuggestedFileName = "c:\my documents\excel\test\" _ & Format(.Range("a1").Value, "yyyy_mm_dd") & ".xls" End With myFileName = Application.GetSaveAsFilename _ ...

Different display names
Hi Is there any way to have an account display differently in the FROM field compared to the GAL (Exchange 2003). We would like the user to appear in the GAL as "Bob User" but when an external recipient reads an email it should be displayed as "Bob of Company <bob.user@company.com>". Cheers Stuart ...

Unlocking named ranges
I am working with a spreadsheet created by a former employee. He used named ranges a lot. I am trying to understand the worksheet. When I see an equation in a cell like =Sum(Shipments) I feel I know what it means. But how do I learn what the actual cell reference is ie = Sum(D2:G2).? TIA Insert a new, empty worksheet into the workbook. Then you can use The Insert-> Name-> Paste menu option and click on the Paste List button to get a listing of all the names and the definitions "JohnL" wrote: > I am working with a spreadsheet created by a former employee. He used...

Adding company name to the "From" field
Hopefully this is an easy problem. We are running Exchange 2003 on Windows Server 2003 in a mixed domain. (Win2k and Win2003 servers) Lets say I am working for a company named "XYZ". The owner of the company wants the "from" line in the email client to say "Bill Smith, XYZ Company". Unfortunately I can not find a way to do this. Any help is appreciated. Bob Hi Bob, Just use ADModify to rewrite the Display name for every user in your company, or for users of that company (if companys are sharing and AD) ADModify can be found here: http://www.gotdotnet.co...

edit suggest names when completing To, cc and bcc fields
Apparently I don't have an Address Book linked to Outlook 2000. No matter, because I seem to be ok with the suggest names feature, which I guess is not Address Book-linked, but linked to a memory bank of names and corresponding addresses typed in during the past. However, here is my question: How do you edit this Suggest Names list? In particular, A. Suppose you want to stop Outlook from suggesting a particular name because it is not current anymore. Worse, you might inadvertantly click on it and send msg to somebody you don't want to receive it. Is there a way to delet...

reading file name from folder function
I am using Access 97. Just wonder if there is a fuction which can read all the file name from a folder and put it to a column in a table. Please let me know. Thanks. Hi. >I am using Access 97. Just wonder if there is a fuction which can read all >the file name from a folder and put it to a column in a table. Please see the getFileInfo( ) function in the tip, "How to compare the contents of two directories," on the following Web page for an example: http://www.access.qbuilt.com/html/vba1.html HTH. Gunny See http://www.QBuilt.com for all your database needs. See http...

Domain name not always needed to log into OWA?
This is something I've wondered about for a while. Why is it that only some of our new Exchange Server installs insist on the OWA login <up to 13 chars. of domain name>\<user name> while others have no trouble with only <user name>? "Julie" <julie@somewhere.org> wrote: >This is something I've wondered about for a while. > >Why is it that only some of our new Exchange Server installs insist on >the OWA login <up to 13 chars. of domain name>\<user name> while >others have no trouble with only <user name>? Probably b...

Named Ranges
Hi! I created several worksheets that contained huge lists, so I created a dynamic named range. Now that the name has been inserted in my array formulas, my Macro runs very slowly. The Macro unprotects one of my sheets, sorts the data in a table, hides the blank rows and the protects the sheet again. There are no related named range formulas in that worksheet, so I'm not sure why it would be affected. The Macro ran quickly when I had a defined range of data. Would giving a named range like 'Date' and having text in my workbook with 'Date' create conflicts? Could this...

Send Emails With A Different Name Than How Its Listed in the GAL
Hi all, I have a quick question: My client is unhappy with how his emails get sent out from MS Outlook. The GAL on our server lists names as [Last Name], [First Name]. This is how the majority of our clients want it. However, he wants his to be [First Name] [Last Name]. So, all recipients getting emails from him will see his name as First Name, Last Name. We can't do this for him on our GAL, since it would obviously cause an inconsistency if we did it only for one name. But, I figured I'd post here to see if anything else can be done to accomodate him. Thanks in advance for your help...

Report names in listbox
I recently upgraded to Access 2007 and am having some trouble with the changes. I have a form with a listbox in which I would like to display the names of all the reports in the database. I've tried using the following as the rowsource for the listbox, but in form view nothing is displayed. Does anyone know how to do this? TIA, Ken Warthen kenwarthen@gmail.com "SELECT MSysObjects.Name FROM MSysObjects WHERE (((Left([Name],1))<"~") AND ((MSysObjects.Type)=-32764)) ORDER BY MSysObjects.Name;" I think you made a slight typo. Try (((Left([Name],1))<>&quo...

Access server name?
Hi Experts: I have been using SQL Server 2005 and I'm now trying to move to Access (Microsoft Office Access 2007). One question, with SQL Server 2005, there is a Windows Service called "SQL Server" which is running all the time and ready to be connected from a database application. In the case of Access, what is the equivalent program? I do not see any Access program in the Windows Service List. Thanks in advance! Polaris In news:OC1gc%23kpHHA.4872@TK2MSFTNGP03.phx.gbl, Polaris <etpolaris@hotmail.com> wrote: > Hi Experts: > > I have been using SQ...

Switching Names Around
Hey gurus- I am getting a list of names imported into Excel. All the names are in the order of LAST NAME FIRST MI/[SPOUSE] FIRST [SPOUSE] MI. All of them have their last name at the beginning, and they're all merged into the same cell. I am trying to print out mailers, so I need the 1st name moved to the back of the line so it prints out normally. How would I write a macro to do this? The only way I can think of is to signal is off the very 1st SPACE- everything before that space gets added to the end of the line. Is this possible to do? How do I do this? I'm not very good at VB, so...

Using a named range as a data source for a chart
Hi, I'm trying to build a chart that that has a named range as its data source. The named range refers to a table that is 2x3 and is called geographydata. Is there any way that I can have the source data for the graph to be geographydata? Thanks! Michael You can enter the name, preceded by the worksheet name and exclamation point, for the data range, but Excel will convert this name to its cell address. If you want the chart to be dynamic as the name changes its size, you have to define a name for each series' data. This will not dynamically change the number of series in the ch...

Doesn't find files w/spaces in name
There are a lot of folders and Excel spreadsheets on our shared drive that I need to open. Most of the folders and file names are named like: get reports\reports sep 2004.xls When I try to open one, Excel doesn't find it and I think it's because there are spaces in the folder names and/or file names. Is there a setting in Excel that will help me get around this? This was working until I had a glitch in Excel and the technician fixed the glitch and this problem appeared. Any help would be appreciated. I found an answer and so far it works. "C:/program files/microsoft off...

Parse Name Field into First Name Last Name
I have a field called [Patient Name] that I want to parse out into a First Name Field and Last Name Field. I am using the Charindex() to find the comma that seperates the First and Last Name, I am then passing the Charindex value to the Left Function to grab the Last Name. Below is what the code looks like: LEFT([Patient Name],Charindex(',', [Patient Name])-1) AS LAST_NAME I am getting the below error when using the above code Invalid length parameter passed to the LEFT or SUBSTRING function. Warning: Null value is eliminated by an aggregate or other SET operation. ...

Not remembering names for autocomplete
We're running Outlook 2002 on a Windows 2000 terminal server with Exchange 5.5 For some reason, the autocomplete feature isn't rememebering names from day to day. A user will send out e-mails, and for the rest of his session it will autocomplete the name if he types it in again - but the next time he launches a session, the autocomplete doesn't remember that name. What are the possible causes and resolutions for this? Corrupt profile. Create a new one. -- Russ Valentine [MVP-Outlook] "Eric" <rvrndlovejoy@yahoo.com> wrote in message news:uG1OB%23iVFHA.3488@...

Recovery Storage Group: Invalid DN Syntax Error on names with comm
I have sucessfully created and mounted an RSG on my Exchange 2003 SP1 server. My problem is when i right click any mailbox in the RSG from the ESM that's name contains a comma (Kleinpeter, Rob) i get error: An Invalid dn syntax has been specified. Facility: LDAP Providor ID no: 80072032 Exchange System Manager This does not happen in the live database or in the RGS with names that do not contain commas. Any help with this would be greatly appreciated. RK "Rob Kleinpeter" <RobKleinpeter@discussions.microsoft.com> wrote in message news:<BD474C10-309D-423A-8736-1759...

Dynamic Button Name?
Hi everone, Can a button name be made dynamic? For example, you create a button and want its name be read from cell A1. So if A1 read "Mike", the button name automatically become "Mike" and so on. Thanks, Mike for a button from the Forms toolbar, you can use this event macro. Put it in the worksheet code module (right-click the worksheet tab and choose View Code") Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Not Intersect(Target, Range("A1")) Is Nothing Then _ Me.Buttons(1).Caption = Range("A1").Value ...

Underscore in Computer name
Hi, hope somebody can help. It looks like some companies are logging email from my company as SPAM. I think it is because the email message look like they have malformed header information due to the fact that my exchange server has a computer name with an underscore in it... I changed the DNS hostname in network settings to reflect a dash instead of an underscore, but the exchange server still appends the underscored name in the message header in the received by section...which causes a bunch of garbage in the header... What are my options, outside of changing my computer name and...

Formula To Bring The Best Name
I have a worksheet that has 9 suppliers names in (C4:L4), there costs for a item in (C19:L19) I want to bring the cheapest suppliers name into cell M4. Need Help! Peter, I remember I replied to your post yesterday. Didnt you tried that ? =INDEX(C4:L4,MATCH(MIN(C19:L19),C19:L19,0)) -- Jacob "peterh" wrote: > I have a worksheet that has 9 suppliers names in (C4:L4), there costs for a > item in (C19:L19) I want to bring the cheapest suppliers name into cell M4. > Need Help! Jacob, Thanks that's great, I missed your reply yesterday. "J...

OWA logon without domain name
Is there a way to set up the OWA logon so that users can either type "domain\username" or type "username" to log on? We used KB article 903942 and Forms-Based Authentication to allow users to log on simply as "username" -- but people who had already been trained to enter "domain\username" are then blocked. Any ideas? Thanks very much in advance. Ron Proschan ...