[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Template automation usingbookmarks

Posted on 2004-08-17
23
Medium Priority
?
277 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
20 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
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

834 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