Results 1 to 2 of 2

Thread: Multiline textbox

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Location
    Oslo
    Posts
    30

    Multiline textbox

    This is a extra thing in similarity to my previous post.

    Iam starting to figure more things out with my codes, but i wonder about
    "txtBringToClass", if this will do the trick so that a user can press enter in the textbox, and this will give a new lin into the the bookmark in document called "bmTaMed". At my first try with only using multiline and enter formfieldbehavior, did not do sufficient, or expected actions.

    In the document, do i need to make the textfield, long? (within the field press enter to apply multiple lines ) Or can i leave it without any like that ?

    I use textfield incase the pop up will not load with the document.
    I also want to protect the form with a blank password, to prevent undecired editing. But will the code work if the template is restricted to only fill in form?

    PHP Code:
    Private Sub cmdDone_Click()
    With ActiveDocument
            
    .Bookmarks("bmVedrørende").Range.Text Me.txtCourse.Value
            
    .Bookmarks("bmKursdato").Range.Text Me.txtDate.Value
            
    .Bookmarks("bmKurstid").Range.Text Me.txtTime.Value
            
    .Bookmarks("bmTaMed").Range.Text Me.txtBringToClass.Value
            
    .Bookmarks("bmHeading").Range.Text Me.cboHeading.Value
    End With
            frmCourseDetails
    .Hide
    End Sub

    Private Sub txtBringToClass_Change()
        
    With Me.txtBringToClass
            myarr 
    Split(multilinetextbox.TextvbNewLine)
            For 
    0 To UBound(myarr)
            
    myarr(i) = Trim(myarr(i))
            
    Next
        End With
    End Sub

    Private Sub frmCourseDetails_Initialize()
        
    With Me.cboHeading        
            
    .AddItem "Invitasjon til kurs"
            
    .AddItem "Endringsmelding"
            
    .AddItem "Oppfriskningskurs"
        
    End With
    End Sub 
    And within the <code> brackets, this is reference to Super Office database codes (just to explain)

    And can i with the bookmarks for like "bmAttfirm" wich is a textfield with cde reference to a customer from db, be able to write code for : save as filename?
    Example: xxx-zzz-yyy-oooo-1234
    xxx=if a customer name would be: Bayline Mechanical Worksop, this will result in: BMW
    zzz=some letters from another bookmark telling me to whom it was sendt to.
    yyy= bookmark who authored it
    oooo= year, or "ddmmyyyy" or "ddmm"
    1234=sequense/serialnr



    Thank u all so much

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Location
    Oslo
    Posts
    30

    Re: Multiline textbox

    Ive tried to do some work on this by my own, but somethings aint just right..
    The code below i've placed in "code for userform"


    Code:
    Option Explicit
    
    Private Sub cmdOk_Click()
    Application.Run "ToggleFormLock"
        Dim strError1 As String
        'strError1 As Integer
        Dim strError2 As String
        'strError2 As Integer
        Dim strError3 As String
        'strError3 As Integer
        Dim strIntDep As String
        'strIntDep As Integer
        Dim strDocType As String
        'strDocType As Integer
        Dim strDep As String
        'strDep As Integer
            If cboIntDep.Text = "Salg" Then 'Shall give an Selection in ComboBox
            strIntDep = "SAM" 'Shall return this value, if picked selection above
            End If
            If cboIntDep.Text = "Service" Then
            strIntDep = "SER"
            End If
            If cboIntDep.Text = "Verksted" Then
            strIntDep = "WS"
            End If
            If cboIntDep.Text = "Kvalitetssikring" Then
            strIntDep = "QA"
            End If
            If cboIntDep.Text = "Sikkerhet Helse Arbeidsmiljø" Then
            strIntDep = "SHA"
            End If
            If cboIntDep.Text = "Finans og økonomi" Then
            strIntDep = "FIN"
            End If
            If cboIntDep.Text = "Lager, materialadministrasjon og logistikk" Then
            strIntDep = "MMA"
            End If
            If cboIntDep.Text = "Administrasjon" Then
            strIntDep = "ADM"
            End If
            If cboIntDep.Text = "Markedsføring" Then
            strIntDep = "PR"
            End If
            If cboIntDep.Text = "Ledelse" Then
            strIntDep = "MAN"
            End If
            If cboIntDep.Text = "Personal" Then
            strIntDep = "HRE"
            End If
            If cboIntDep.Value = "Må velge en" Then 'Shall give an Selection in ComboBox
            strIntDep = MsgBox("Hei Du MÅ velge en internavdeling") 'Shall return this value, if picked selection above
            MsgBox (strError1) 'Notify user that selection must be made!
            End If
            If cboDep.Value = "Må velge en" Then
            strError1 = MsgBox("Hei Du MÅ velge et avdelingskontor")
            MsgBox (strError2)
            End If
            If cboDocType.Value = "Må velge en" Then
            strError2 = MsgBox("Hei Du MÅ velge en dokument-type")
            MsgBox (strError3)
            End If
            If cboDep.Value = "Fredrikstad" Then
            strDep = ("FRE")
            End If
            If cboDep.Value = "Kristiansand" Then
            strDep = ("KRS")
            End If
            If cboDep.Value = "Stavanger" Then
            strDep = ("STV")
            End If
            If cboDep.Value = "Sandvika" Then
            strDep = ("SAN")
            End If
            If cboDocType.Value = "Generell Prosedyre" Then
            strDocType = ("GP")
            End If
            If cboDocType.Value = "Spesifikasjon" Then
            strDocType = ("SPC")
            End If
            If cboDocType.Value = "Brukerveiledning" Then
            strDocType = ("GUI")
            End If
            If cboDocType.Value = "Skjema" Then
            strDocType = ("FO")
            End If
            If cboDocType.Value = "Transport og håndteringsinstruksjon" Then
            strDocType = ("THI")
            End If
            
    Application.Run "ToggleFormLock"
    End Sub
    
    Private Sub MyDocHeader_Initialize(cboIntDep As Long, cboDep As Long, cboDocType As Long)
    With activedocument
        .Bookmarks("IntDep").Range.Text = cboIntDep
        .Bookmarks("DocType").Range.Text = cboDocType
        .Bookmarks("Dep").Range.Text = cboDep
    End With
    'Adds choices to the internal department pulldown
    With Me.cboIntDep
        .AddItem "Må velge en", 1
        .AddItem "Salg", 6
        .AddItem "Service", 9
        .AddItem "Kvalitetsikring", 5
        .AddItem "Sikkerhet Helse Arbeidsmiljø", 12
        .AddItem "Finans og økonomi", 7
        .AddItem "Lager og logistikk", 8
        .AddItem "Administrasjon", 2
        .AddItem "Verksted", 10
        .AddItem "Markedsføring", 11
        .AddItem "Ledelse", 3
        .AddItem "Personal", 4
    End With
    'Adds choices for the branch offices
    With Me.cboDep
        .AddItem "Må velge en", 1
        .AddItem "Fredrikstad"
        .AddItem "Kristiansand"
        .AddItem "Sanvika"
        .AddItem "Stavanger"
    End With
    'Adds choices for the type of document
    With Me.cboDocType
        .AddItem "Må velge en", 1
        .AddItem "Generell Prosedyre"
        .AddItem "Spesifikasjon"
        .AddItem "Brukerveiledning"
        .AddItem "Skjema"
        .AddItem "Transport og håndteringsinstruksjon"
    End With
    End Sub
    and a module for this:
    Code:
    Option Explicit
    
    Sub ToggleFormLock()
    '**********************
    'code by Erik Thoresen
    '@Etrola.com,
    'Etrola LTD
    '**********************
    'PURPOSE
    'quickly checks dot/doc state and toggles opens/closes as
    'needed to enter data. Activatepassword portion of code if
    'a password is being used.
    '**********************
    
    'if locked , unlock, else lock
    'First option
    If activedocument.ProtectionType = wdAllowOnlyFormFields Then
        activedocument.Unprotect Password:=""
    'Else: activedocument.Protect Type:=wdAllowOnlyFormFields, _
        NoReset:=True, Password:=""
    End If
    'If activedocument.ProtectionType = wdAllowOnlyFormFields Then
    'MsgBox "Dokumentet er allerede beskyttet"
    'End If
    
    End Sub
    'Second option
    'Sub toolsprotectdocument()
    'If activedocument.ProtectionType = wdAllowOnlyFormFields Then
      ' activedocument.Protect wdAllowOnlyFormFields, True, ""
       
    'Else
    'Dialogs(wdDialogToolsUnprotectDocument).Show
    'End If
    
    'If activedocument.ProtectionType = wdNoProtection Then
    'activedocument.Protect Type:=wdAllowOnlyFormFields, _
    'NoReset:=True, Password:=""
    'Else
    'MsgBox "Document is already protected"
    'End If
    'End Sub
    And a module for this:
    Code:
    Option Explicit
    
    Sub UpdateHeader()
    '
    ' UpdateHeader Makro
    ' Updates the header with the supplied information
    ' Opens the header to update REF field
    
    ' Closes header and then relocks the doc
    Application.Run "ToggleFormLock"
            If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
            ActiveWindow.Panes(2).Close
            End If
                If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
                    ActivePane.View.Type = wdOutlineView Then
                    ActiveWindow.ActivePane.View.Type = wdPrintView
                End If
                ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
                Selection.WholeStory
                Selection.Fields.Update
                ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
            
       If activedocument.Bookmarks.Exists("IntDep") = True Then
          activedocument.Bookmarks("IntDep").Select
       End If
       If activedocument.Bookmarks.Exists("DocType") = True Then
          activedocument.Bookmarks("DocType").Select
       End If
       If activedocument.Bookmarks.Exists("Dep") = True Then
          activedocument.Bookmarks("Dep").Select
       End If
    '.Bookmarks("IntDep").Range.Text = cboIntDep
    '.Bookmarks("DocType").Range.Text = cboDocType
    '.Bookmarks("Dep").Range.Text = cboDep
    Application.Run "DocRefHeaderUpdate!ToggleFormLock"
    End Sub
    My goals with this is to edit header, if protected form, unprotect, update bookmarks (since fields cant be placed in header)

    Replace the selection in dropdowns with acronyms (that now doesent populate in form)
    fill out the bookmarks that give me a doc.no that make sence, and can be used for later coding.

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width