Solved

Template automation usingbookmarks

Posted on 2004-08-17
23
267 Views
Last Modified: 2012-08-14
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
0
Comment
Question by:JasonJewett
  • 10
  • 9
23 Comments
 
LVL 37

Expert Comment

by:Joanne M. Orzech
Comment Utility
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
 

Author Comment

by:JasonJewett
Comment Utility
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
 
LVL 37

Expert Comment

by:Joanne M. Orzech
Comment Utility
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
 

Author Comment

by:JasonJewett
Comment Utility
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
 
LVL 37

Expert Comment

by:Joanne M. Orzech
Comment Utility
If you're doing a merge, then why do you need bookmarks?
0
 

Author Comment

by:JasonJewett
Comment Utility
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
 
LVL 37

Expert Comment

by:Joanne M. Orzech
Comment Utility
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
 

Author Comment

by:JasonJewett
Comment Utility
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
 
LVL 37

Expert Comment

by:Joanne M. Orzech
Comment Utility
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
 

Author Comment

by:JasonJewett
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:JasonJewett
Comment Utility
Update:  after the first run I get : "Variable name already exists" errors.  
0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
Comment Utility
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
 
LVL 37

Expert Comment

by:Joanne M. Orzech
Comment Utility
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
 

Author Comment

by:JasonJewett
Comment Utility
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
 

Author Comment

by:JasonJewett
Comment Utility
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
 
LVL 37

Expert Comment

by:Joanne M. Orzech
Comment Utility
Just record a macro and place the text box where you want.... then you can view the code via Alt F11.

0
 

Author Comment

by:JasonJewett
Comment Utility
did that and it still inserts at the top.  :(
0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
Comment Utility
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
 

Author Comment

by:JasonJewett
Comment Utility
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
 

Accepted Solution

by:
modulo earned 0 total points
Comment Utility
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Do you ever need to create a 20 page Word document for some testing purpose? Are you tired of copying & pasting old boring "lorem ipsum" text over and over again, increasing font size and line space in order to make the document 20+ pages long? Look…
I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now