MsOf03 [RESOLVED] VBA pop up-VBForums
Results 1 to 5 of 5

Thread: [RESOLVED] VBA pop up

  1. #1

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

    Resolved [RESOLVED] VBA pop up

    Hi yall.

    I'm sitting here getting a bit frustrated, as i usually do, when i'm sitting with this codes that doesnt work for me.

    The pop up loads, but i get an error message, as attached images tells.

    Private Sub CommandButton1_Click()
    With ActiveDocument
    .Bookmarks("bmKursdato").Range ("TextBox1")
    .InsertBefore TextBox1
    .Bookmarks("bmKursklokke").Range ("TextBox2")
    .InsertBefore TextBox2
    .Bookmarks("bmTamed").Range ("TextBox3")
    .InsertBefore TextBox3
    End With
    UserForm1.hide
    End Sub

    Where do i do the wrong code?

    Thank you
    Attached Images Attached Images   
    Attached Files Attached Files

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    19,939

    Re: VBA pop up

    i am unable to be sure from your code as to what you are trying to do, my guess is put the content of textbox1 into the form field
    try like
    vb Code:
    1. ThisDocument.Bookmarks("bmKursdato").Range.Fields(1).Result.Text = textbox1
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

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

    Re: VBA pop up

    Ok, thanks. That solves the issue for my first textfield that i want to fill, but not the next two

    Highlightened and marked bm2 and bm3

    Private Sub CommandButton1_Click()
    With ActiveDocument.Bookmarks("bmKursdato").Range.Fields(1).Result.Text = TextBox1
    .Bookmarks("bmKurstid").Range.Fields(2).Result.Text = TextBox2
    .Bookmarks("bmTamed").Range.Fields(3).Result.Text = TextBox3
    End With
    UserForm1.hide
    End Sub
    Attached Images Attached Images  

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    19,939

    Re: VBA pop up

    they should all be fields(1)
    only one field to each bookmark i think
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

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

    Re: VBA pop up

    Code:
     With ActiveDocument
            .Bookmarks("bmKursdato").Range.Text = Me.TextBox1.Value
            .Bookmarks("bmKurstid").Range.Text = Me.TextBox2.Value
            .Bookmarks("bmTamed").Range.Text = Me.TextBox3.Value
        End With
    Was the way to do it..

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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.