Solved

Template automation usingbookmarks

Posted on 2004-08-17
23
272 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 9
23 Comments
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 11826201
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
ID: 11826264
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
ID: 11826336
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

 

Author Comment

by:JasonJewett
ID: 11826504
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
ID: 11827233
If you're doing a merge, then why do you need bookmarks?
0
 

Author Comment

by:JasonJewett
ID: 11830999
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
ID: 11831669
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
ID: 11831996
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
ID: 11832832
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
ID: 11833475
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
 

Author Comment

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

Expert Comment

by:Joanne M. Orzech
ID: 11834582
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
ID: 11837417
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
ID: 11842002
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
ID: 11843029
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
ID: 11843860
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
ID: 11844063
did that and it still inserts at the top.  :(
0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 11844350
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
ID: 11876370
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
ID: 12637659
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

737 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