Template automation usingbookmarks

I'm attempting to create a document template that acts as a merge master doc and also as some automation in it.

I have a button on the template that pops up a form that allows the user to select "Sent Via" options.  When the user clicks on the desired item, I have code that looks for a bookmark, deletes any values in the cell that the bookmark is in, and then replaces that cell with the clicked value.  It works beautifly in the template.  The problem is that once a new document is created from it (via the merge), the bookmarks don't seem to make it over and I get "bookmark not found" errors.

Along this line, i lifted the cool clickable checkboxes from the generic "conteporary fax" to put on my template.  They also work fine o my template, but not on any new documents.

Any thoughts?  I have seen references to "docvariable" fields, but I'm not familiar with them.

Thanks in advance,
Jason
JasonJewettAsked:
Who is Participating?
 
moduloConnect With a Mentor Commented:
PAQed with points refunded (500)

modulo
Community Support Moderator
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
What kind of form pops up Jason?  A VB user form?  If so, this will be fairly easy to do.  As for the checkboxes - that should be easy too.  What is your data source for the merge?

I use docvariables almost always ... a lot of the other experts here use bookmarks and stuff but I use docvariables most of the time so I can explain both to you if you need it.  Just need a little more info from you.




0
 
JasonJewettAuthor Commented:
It is a VB User form.  The merge is controlled via a program called ProWrite.  We use that to pull info from Outlook Public Folders.  The goal is to be able to use a Word template and have ProWrite merge the info we need - typically contact info like addreses.  Once the merge is complete, the buttons (and checkboxes) will need to be used to further config the document.

Thanks!
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
Joanne M. OrzechManager, Document Services CenterCommented:
OK - well - let's take one step at a time.  I'm not familiar with ProWrite, but am very familiar with merges so....see if this helps.  Then we can address the checkbox issue - that's the easy part.

http://www.slipstick.com/contacts/startletter.htm

http://www.slipstick.com/contacts/printlabel.htm





0
 
JasonJewettAuthor Commented:
Thanks.  I've actually got the merge part (from Prowrite) working nifty-good.  :)  My issue is that after the merge, parts of the template (notably the bookmarks and the checkbox functionality) no longer seem to be attached to the document.  * raises eyebrows*  After the merge, when I click my little button (that displays the list in the VB Form) I get a "can't find bookmark" error.  If I open the template straight-up it works fine.

Thanks for the quick responces.
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
If you're doing a merge, then why do you need bookmarks?
0
 
JasonJewettAuthor Commented:
I use the bookmarks as a place-holder so that my dropdown box knows where to but the selected data.  The dropdown list needs to be selected AFTER the merge is complete.  (same with the checkboxes).

I'm certainly not married to the bookmark idea.  If there is a better way I'm all ears.  My only constraint is that the info selected via the VB form must be after the merge.
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
I would use a docvariable:

ActiveDocument.Variables.Add Name:="VariableName", value:=frmUserForm.DropDown1.Text
' you may or may not need the following line of code to view the variable.... I'm not sure what your VB does....
ActiveDocument.Fields.Update

Can you give that a try?
0
 
JasonJewettAuthor Commented:
Here is the code I have for the form. It executes when a user doubleclicks on an entry on the form.   Where whould I use the docvariable?  Do I need to set it someplace in the document - like a bookmark - so that the text is entered in the correct location?

Private Sub ListTitle_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    '  Find location
    Selection.GoTo What:=wdGoToBookmark, Name:="From"
    '  Delete previous data
    Selection.SelectCell
    Selection.Delete Unit:=wdCharacter, Count:=1
    '  Add new data from form
    Selection.Text = ListBoxUserTitles.ListTitle.Text
   
    '  Unload form
    Call UnloadUserTitlesList

End Sub

again, thanks for the assistance!
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Hey Jason

Yes - put the docvariable where the bookmark is ... then try this:

Sub ListTitle()
    ActiveDocument.Variables.Add Name:="VariableName", value:=frmUserForm.DropDown1.Text ' change the name of your form and control here
    Selection.WholeStory
    ActiveDocument.Fields.Update
    Selection.HomeKey
    Call UnloadUserTitlesList
End Sub

0
 
JasonJewettAuthor Commented:
Thanks.  Here is what happens:

1.  docvariable replacement works great - the selected text displays correctly based on what I pick.  However, it appends to whatever is already there.  I think I can reused the code to delete the cell where the data is though so I'm not concerned.  
2.  More importantly, after the merge, the new merged document does not have the docvariable field.  After the merge, I can't use the button.  :(

0
 
JasonJewettAuthor Commented:
Update:  after the first run I get : "Variable name already exists" errors.  
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
OK - I'm in a crunch right now Jason... my apologies.  Will get back to you as soon as I can....you may have to go back to the bookmark method :(  Let me think about it.

0
 
Joanne M. OrzechManager, Document Services CenterCommented:
I think I may have an idea...so sorry for the delay - but I don't have the info right now.  Will post tomorrow.



0
 
JasonJewettAuthor Commented:
I had an idea last night that seems to be working - I'm stll testing though.  I'm now using an embedded field to house the results.  The field seems to migrate over the the new document after the merge so the button still works!    Now I'm trying to see how to put merge fields into a text field and not having much luck!
0
 
JasonJewettAuthor Commented:
Any idea how to control the placement of a control (text box) that is added to a document via code?  It always goes to the top :(
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Just record a macro and place the text box where you want.... then you can view the code via Alt F11.

0
 
JasonJewettAuthor Commented:
did that and it still inserts at the top.  :(
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
What happens when you run this?

Sub Jason()
    ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 139.05, _
        216.2, 306#, 162#).Select
    Selection.ShapeRange.TextFrame.TextRange.Select
    Selection.Collapse
    Selection.ShapeRange.Select
    Selection.ShapeRange.Fill.Visible = msoTrue
    Selection.ShapeRange.Fill.Solid
    Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 255, 255)
    Selection.ShapeRange.Fill.Transparency = 0#
    Selection.ShapeRange.Line.Weight = 0.75
    Selection.ShapeRange.Line.DashStyle = msoLineSolid
    Selection.ShapeRange.Line.Style = msoLineSingle
    Selection.ShapeRange.Line.Transparency = 0#
    Selection.ShapeRange.Line.Visible = msoTrue
    Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0)
    Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
    Selection.ShapeRange.LockAspectRatio = msoFalse
    Selection.ShapeRange.Height = 162#
    Selection.ShapeRange.Width = 306#
    Selection.ShapeRange.TextFrame.MarginLeft = 7.2
    Selection.ShapeRange.TextFrame.MarginRight = 7.2
    Selection.ShapeRange.TextFrame.MarginTop = 3.6
    Selection.ShapeRange.TextFrame.MarginBottom = 3.6
    Selection.ShapeRange.RelativeHorizontalPosition = _
        wdRelativeHorizontalPositionColumn
    Selection.ShapeRange.RelativeVerticalPosition = _
        wdRelativeVerticalPositionParagraph
    Selection.ShapeRange.Left = wdShapeCenter
    Selection.ShapeRange.Top = InchesToPoints(2)
    Selection.ShapeRange.LockAnchor = False
    Selection.ShapeRange.WrapFormat.AllowOverlap = True
    Selection.ShapeRange.WrapFormat.Side = wdWrapLargest
    Selection.ShapeRange.WrapFormat.DistanceTop = InchesToPoints(0)
    Selection.ShapeRange.WrapFormat.DistanceBottom = InchesToPoints(0)
    Selection.ShapeRange.WrapFormat.DistanceLeft = InchesToPoints(0.13)
    Selection.ShapeRange.WrapFormat.DistanceRight = InchesToPoints(0.13)
    Selection.ShapeRange.WrapFormat.Type = wdWrapTight
End Sub
0
 
JasonJewettAuthor Commented:
Sorry for the delay -  I took a mini vacation!

I changed direction and found a less painful way to get the data into the correct cell.  I used this:

ActiveDocument.Tables(8).Columns(3).Cells(1).Range.Text = Me.ListTitle.Text
Me.Hide

This places the text from the form in the 8th table, third column, first cell.

Thanks for your help:  what is the accepted etiquette for points distribution here?  
Jason
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.