Hi,
I would like to have a title associated with each page. I am using the Page.Name in my Background Title Block. But I would also like to have a longer field to use for a longer description of the Page.
Basically my Page.Name would be something like DWG-1234 but I would like to have a field associated with each page that I can give a description "Boiler #3 Fuel Controls" And of course once created, I would like to place it in my title block on the background so that each new page would have it.
Any ideas?
thanks
Shape Data is the way to go for this. Ensure you have the Develoiper tab enabled to get easy access to this, or you can also do so via the Drawing Explorer window. Add the shape data section for the page, add a data item for your page title. Then in the title block you can access the page's shape data.
Thanks for the reply Paul. I was kind of headed in that direction. But I am working on a template where initially there are no foreground pages. So I was looking for away to do this somehow from the background pages, which will be used when people insert a page and use the background page which contains the border.
I added data to the background page and was able to link to it via ThePage!Prop.Row_1.Value, but the data seems to be the same on each page. So if I change it on one, all of them change. Which kind of makes sense, that the background page is the same on all pages using it.
I can create a first page (Foreground) in the template and then add data to it, and a text title connected to it. Then have people duplicate it for each of the pages, but I was trying to avoid having to require this. Would prefer if they could just insert a page.
I could add the text shape and give it the data then place on the background. But I think it will still be the same issue, If I change it on one page, all of them will change.
If you have any more ideas, I would love to hear them.
I sure do wish I could just add a property to the page recordset similar to Page.Name Visio seems to have a mechanism to allow connection to it on the background, but uses the foreground page.
Thanks
Hi,
To display a page name I insert a text field and insert a field with this formula: =ThePage!PAGENAME()
Hope I understood the problem right,
regards,
Yes I can do the Page.Name but would like to have another field associated with the Page that is longer and different than the Page.Name. Since the Page Name is used in the tab, it is usually keep at a shorter 12 or so limit. But I would like to have another field where I might enter a very verbose description of the page.
Not really sure what you are trying to do here...but
Define a box (aka legend or whatever)
You can define 2 cells
Props.title
Props.intro
Set eventdblclk = docmd(1312)
Then insert fields ==>props==>props.title and props.intro
Ok...so now when double click the lengin, you can update title and introduction/description. Those updates are presented in the text box
Now one thing that makes this interesting is that this can be a shape on a stencil so you can use wherever with no VBA.
Again, not sure what problem you are trying to solve....so this is just a thought
Thanks for the tips Vojo.
Especially the part about no vba code.
I currently have vba code that is run when a Page is Added.
The code basically adds a section and property to the page shapesheet. (Prop.Sheet_Title)
I then draw a rectangle on the position I want (lining up with the border from the background). I then set this to the ThePage!Prop.Sheet_Title
All is working good, now trying to get to this data creating a table of contents. For some reason I can't find the field.
I will also study your ideas and apply them if it makes it cleaner.
The basic idea is to have a Title Associated with each page. The Page.Name field is great, but I would like another field where I can be more verbose in describing the page. I can create this by hand after inserting page, but would like it to automatically happen whenever someone inserts a page.
Here is a copy of the code so far.
Sub Add_Title()
' Add Custom Property to Sheet for Sheet Titles
Dim vsoShape As Visio.Shape
Set vsoShape = Visio.ActivePage.PageSheet
vsoShape.AddSection visSectionProp
vsoShape.AddNamedRow visSectionProp, "Sheet_Title", visTagDefault
vsoShape.Cells("Prop.Sheet_Title").Formula = """Dwg Title"""
' Draw Text Box to link to Custom Sheet Title
Application.ActiveWindow.Page.DrawRectangle 13#, 1.068, 16.5, 1.5648
Set vsoShape = Visio.ActiveWindow.Selection(1)
vsoShape.Cells("FillPattern") = 0
vsoShape.Cells("Char.Font") = 21
vsoShape.Cells("Char.Size").Formula = "8 pt"
vsoShape.AddSection visSectionProp
vsoShape.AddNamedRow visSectionProp, Prop_Rows_Name, visTagDefault
Set vsoCharacters = vsoShape.Characters
'vsoCharacters.Text = "sheet title"
vsoCharacters.Begin = 0
vsoCharacters.End = 6
vsoCharacters.AddCustomFieldU "ThePage!Prop.Sheet_Title", visFmtStrNormal
End Sub
This sub is called from
Private Sub Document_PageAdded(ByVal Page As IVPage)
Sheet_Title.Add_Title
Now I am trying to access this field when created a Table of Contents
I borrowed this code from some others on this site
It loops thru each page stopping once it reaches the background pages.
' loop through all the pages
For Each PageToIndex In Application.ActiveDocument.Pages
'exit when it hits the first background page (don't want those in the ToC)
If PageToIndex.Background Then Exit For
If Not PageToIndex.Name = m_deletedPageName Then
'append the page number, a tab, the page name, and a return to the ToC text shape
TOCEntry.Text = TOCEntry.Text + CStr(PageToIndex.Index) + vbTab + PageToIndex.Name + vbNewLine
This works great but now I am trying to add the field created for each page but I cant seem to find the correct syntax or the cell/field itself. Maybe PageToIndex.ShapeSheet is not where it is located?
PageToIndex.PageSheet.Cells("Prop.SheetTitle")
I've tried several combinations but it always dies
Any ideas on how to reference this field
The Text link is ThePage!Prop.Sheet_Title and works fine.
Thanks Again
PageSheet is definitely the right place.
Please check if pagetoindex is properly assigned and that prop.sheettitle exists
To do so insert intermediate assignments:
set pg = pagetoindex .... (check for pg)
debug.print prop.sheettitle (check for result)
HTH, Y.
Thanks Yacine,
I am a definitely a visio hacker not programmer and was wondering how to do some immediate printing. Will help me a lot on debugging!
Ill report back when find out more details
Ok, here was how I finally got to the value in Prop.Sheet_Titel
Set vsoShape = PageToIndex.Shapes("ThePage")
Set vsoCell = vsoShape.Cells("Prop.Sheet_Title")
Debug.Print PageToIndex.Name + vbTab + "Title: " + vbTab + vsoCell.ResultStr(Visio.visNone)
Yes, now I see it. It was the ".resultstr(visio.visnone)".