Textfield at fixed location in the window

D

dani

Hi there

I want to put a text field into the lower right corner of the window
(not the page, this can be done in the text's shapesheet), and it should
be displayed there even if the user scrolls on the document or zooms in.

Is this possible? And if yes, how?

thanks

Daniel
 
A

Al Edlund

I use something like this to keep text boxes sized correctly and at the same
place on the drawing.
al


' this is where we initialize the rectangles with user
' cells and then change the necessary cells so that if
' the page size changes the rectangles will remain as
' they appeared before the scale change

Public Sub subAntiScaling(objRect As Visio.Shape, intFieldNr)
Dim objcell As Visio.Cell
Dim blnResult As Boolean

On Error GoTo AntiScaling_Err

objRect.Name = "textfield_" & intFieldNr

objRect.AddSection visSectionUser
blnResult = funcAddUserPropertyToShape(objRect, "width",
"width", "width", _
objRect.Cells("Width").ResultIU, "width")
blnResult = funcAddUserPropertyToShape(objRect,
"height", "height", "height", _
objRect.Cells("height").ResultIU, "height")
blnResult = funcAddUserPropertyToShape(objRect, "pinX",
"pinX", "pinX", _
objRect.Cells("pinx").ResultIU, "pinX")
blnResult = funcAddUserPropertyToShape(objRect, "piny",
"piny", "piny", _
objRect.Cells("piny").ResultIU, "piny")


Set objcell = objRect.Cells("width")
objcell.Formula =
"user.width*(ThePage!DrawingScale/ThePage!PageScale)"
Set objcell = objRect.Cells("height")
objcell.Formula =
"user.height*(ThePage!DrawingScale/ThePage!PageScale)"
Set objcell = objRect.Cells("pinx")
objcell.Formula =
"user.pinx*(ThePage!DrawingScale/ThePage!PageScale)"
Set objcell = objRect.Cells("piny")
objcell.Formula =
"user.piny*(ThePage!DrawingScale/ThePage!PageScale)"

objRect.Cells("Para.HorzAlign").Formula = visHorzLeft

Exit Sub

AntiScaling_Err:

If Err > 0 Then
Debug.Print "Err in AntiScaling " & Err & " " & Err.Description
End If

Resume Next

End Sub
 
J

jmc

Hi Al

I found this feature very interesting, and I tried to put it on a Visio 2002 document. What I did was
- I copied your code and I put it on the ThisDocument
-Then on a shape I create an Action in the Actions section with the command RUNADDON("ThisDocument.subAntiScaling")
But when Call this procedure nothing happens. My questions are
- where I put the code and how to execute this procedure
- How can applie this procedure to more than one text box

thanks

JM

Your Code is bellow

Public Sub subAntiScaling(objRect As Visio.Shape, intFieldNr
Dim objcell As Visio.Cel
Dim blnResult As Boolea

On Error GoTo AntiScaling_Er

objRect.Name = "textfield_" & intFieldN
objRect.AddSection visSectionUse
blnResult = funcAddUserPropertyToShape(objRect, "width", "width", "width",
objRect.Cells("Width").ResultIU, "width"
blnResult = funcAddUserPropertyToShape(objRect, "height", "height", "height",
objRect.Cells("height").ResultIU, "height"
blnResult = funcAddUserPropertyToShape(objRect, "pinX", "pinX", "pinX",
objRect.Cells("pinx").ResultIU, "pinX"
blnResult = funcAddUserPropertyToShape(objRect, "piny", "piny", "piny",
objRect.Cells("piny").ResultIU, "piny"

Set objcell = objRect.Cells("width"
objcell.Formula = "user.width*(ThePage!DrawingScale/ThePage!PageScale)
Set objcell = objRect.Cells("height"
objcell.Formula = "user.height*(ThePage!DrawingScale/ThePage!PageScale)
Set objcell = objRect.Cells("pinx"
objcell.Formula = "user.pinx*(ThePage!DrawingScale/ThePage!PageScale)
Set objcell = objRect.Cells("piny"
objcell.Formula = "user.piny*(ThePage!DrawingScale/ThePage!PageScale)

objRect.Cells("Para.HorzAlign").Formula = visHorzLef

Exit Su

AntiScaling_Err

If Err > 0 The
Debug.Print "Err in AntiScaling " & Err & " " & Err.Descriptio
End I

Resume Nex

End Sub
 
A

Al Edlund

first of all this is a subroutine that is called by something else, thus it
cannot be a standalone macro.

As input it requires an object (in my case it is a pointer to a rectangle).
It is intended to demonstrate how, after an object is created, to modify the
objects shapesheet so that when a page is rescaled the object does not
change size. The routine is generic and is called as often as necessary from
within the calling routine. In my case I am adding text boxes to a page that
show custom properties from the page sheet, usually about six or seven times
when creating a new page depending on the number of text boxes I need.
Al

jmc said:
Hi Al,

I found this feature very interesting, and I tried to put it on a Visio 2002 document. What I did was:
- I copied your code and I put it on the ThisDocument.
-Then on a shape I create an Action in the Actions section with the
command RUNADDON("ThisDocument.subAntiScaling").
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top