Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-10-2013, 11:19 AM
MaxInCO MaxInCO is offline Calculate the coordinates of a DocVariable, Bookmark or paragraph. Windows 7 64bit Calculate the coordinates of a DocVariable, Bookmark or paragraph. Office 2010 64bit
Novice
Calculate the coordinates of a DocVariable, Bookmark or paragraph.
 
Join Date: Dec 2013
Location: Denver
Posts: 9
MaxInCO is on a distinguished road
Default Calculate the coordinates of a DocVariable, Bookmark or paragraph.


My VB application uses a set of Word templates to create a series of PDFs, into some of which get inserted digital signature fields. My current challenge involves locating that digital signature field accurately since the content of the Word documents is not static. Some paragraphs (bullets) get deleted based on user specified criteria, which causes the salutation to move vertically.

What I've come up with so far is to place a small square shape just above the salutation in my templates, make all my bullet adjustments, calculate the coordinates of the Shape (which moves), and then delete it prior to generating the PDF. However, this Shape is somewhat of a nuisance to manage.

Instead, is there any way to calculate the dynamic coordinates/vertical location of a DocVariable field, bookmark or paragraph so I don't have to deal with this Shape in all my templates?

Thanks.
Reply With Quote
  #2  
Old 12-10-2013, 04:59 PM
MaxInCO MaxInCO is offline Calculate the coordinates of a DocVariable, Bookmark or paragraph. Windows 7 64bit Calculate the coordinates of a DocVariable, Bookmark or paragraph. Office 2010 64bit
Novice
Calculate the coordinates of a DocVariable, Bookmark or paragraph.
 
Join Date: Dec 2013
Location: Denver
Posts: 9
MaxInCO is on a distinguished road
Default

Solved. Found the solution.

Code:
 
dim SigPosY as long
SigPosY = wdocTemplate.Bookmarks("DigSigPos1").Range.Information(wdVerticalPositionRelativeToPage)
Returns the vertical position of the Bookmark in points.

Cheers.
Reply With Quote
  #3  
Old 12-10-2013, 06:27 PM
macropod's Avatar
macropod macropod is offline Calculate the coordinates of a DocVariable, Bookmark or paragraph. Windows 7 32bit Calculate the coordinates of a DocVariable, Bookmark or paragraph. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,375
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I'm curious as to why you need the vertical offset (you can get a horizontal one as well), when you can address the bookmark range directly without even knowing what page it's on.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 12-11-2013, 09:17 AM
MaxInCO MaxInCO is offline Calculate the coordinates of a DocVariable, Bookmark or paragraph. Windows 7 64bit Calculate the coordinates of a DocVariable, Bookmark or paragraph. Office 2010 64bit
Novice
Calculate the coordinates of a DocVariable, Bookmark or paragraph.
 
Join Date: Dec 2013
Location: Denver
Posts: 9
MaxInCO is on a distinguished road
Default

Since the content of my Word document changes, which results in a dynamic verticality, I was having a difficult time calculating where to insert the signature field without a marker that would move with my content. Shapes act strangely and inconsistently, at least in my experience. All the bookmark does, in this case, is serve as that moving marker, and it seems to be far more stable than my previous method of using a shape.

Previously, all the advice I received was that the vertical position of a bookmark was not attainable. I was really glad to finally learn differently. And it came from a fairly old post I just stumbled upon.

The horizontal position is not a problem since it's based on my left margin, but I do realize I can get the offset the same way if needed.

If there is a better suggestion as to how I might do this more effeciently I'd love to read it.

Thanks.
Reply With Quote
  #5  
Old 12-11-2013, 02:39 PM
macropod's Avatar
macropod macropod is offline Calculate the coordinates of a DocVariable, Bookmark or paragraph. Windows 7 32bit Calculate the coordinates of a DocVariable, Bookmark or paragraph. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,375
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Since you have the bookmark, you can simply insert the sig as an inlineshape at that point. If you need, you can then use the converttoshape method to apply text-wrapping. No need to calculate coordinates.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 12-11-2013, 03:28 PM
fumei fumei is offline Calculate the coordinates of a DocVariable, Bookmark or paragraph. Windows 7 64bit Calculate the coordinates of a DocVariable, Bookmark or paragraph. Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

maxInCO, macropod is talking about something like this:
Code:
Sub UpdateBM2(strBM As String, strImageName As String)
Dim r As Range
 Set r = ActiveDocument.Bookmarks(strBM).Range
 r.InlineShapes.AddPicture FileName:=strImageName, LinkTofile:=False
 ActiveDocument.Bookmarks.Add Name:=strBM, Range:=r
End Sub
Sub InsertTheSignature()
Call UpdateBM2("SignatureHere", "c:\TestDocs\Signature1.jpg")
End Sub
The first subroutine is a generic procedure that allows you to insert an image into a bookmark (named "SignatureHere" in this case), without deleting that bookmark. You need to do this in order to permit multiple replacements into a bookmark. It is important to understand that this functions REGARDLESS of where the bookmark is. Placement and position is irrelevant, the code puts the image in the bookmark, period.

The second procedure (InsertTheSignature) calls the insertion procedure with the variable of the image file. Needless to say it would also be possible to have a process to get the file name by user input, or a list of signature that you can select.

You can of course change the parameters like LinkToFile, SaveWithDocument of AddPicture.

And, as macropod mentions you can use the converttoshape method to apply text-wrapping
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculate the coordinates of a DocVariable, Bookmark or paragraph. Narrow Paragraph to Wide Paragraph HELP icloudy Word 1 12-09-2012 03:49 PM
Calculate the coordinates of a DocVariable, Bookmark or paragraph. x,y,z coordinates with single space "need tab" gsrikanth Excel 1 07-07-2012 08:16 AM
calculate age userman Excel 8 06-02-2012 10:59 PM
Calculate the coordinates of a DocVariable, Bookmark or paragraph. DOCVARIABLE copy paste special cyndor Word 2 04-06-2012 03:57 AM
Calculate the coordinates of a DocVariable, Bookmark or paragraph. [Word 2007] How to hyperlink directly another word file chapter/paragraph/bookmark? LeeFX Word 4 05-05-2011 05:53 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:11 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft