Results 1 to 4 of 4

VBA: Reset Field Code

Threaded View

  1. #1
    Registered User
    Join Date
    07-31-2012
    Location
    Bangalore
    MS-Off Ver
    Excel 2010
    Posts
    2

    VBA: Reset Field Code

    Hi,
    I am new to this forum and this is my first post. (Even though I have used the forum extensively as a Guest )

    I have coded this macro that will change the display text of a from field in word. I have made a word document with checkboxes, which I am protecting to activate the checkboxes. However I want the users to enter certain data to the document. For this I have added a ‘MACROBUTTON’ field, which will trigger below procedure:

    Dim strProject As String
    pType = ActiveDocument.ProtectionType
    
    If pType = wdAllowOnlyFormFields Then
    ActiveDocument.Unprotect
    End If
    
    strProject = InputBox(Prompt:="Please add the project name", Title:="Add Project", xpos:=7500, ypos:=5000)
    
    If strProject = "" Then 'in case user clicks cancel in the inputbox
    strProject = "Double-click here to add project"
    End If
    
    ActiveDocument.Fields(1).Code.Text = "MACROBUTTON addProject " & strProject 're-coding the form field
    
    ActiveDocument.Protect Type:=wdAllowOnlyFormFields 'enabling checkboxes
    
    Set pType = Nothing
    I wanted to know how robust the macro is? And possible ways to improve it?

    Thank you
    Last edited by arlu1201; 07-31-2012 at 04:04 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1