Author Topic: Assigning numbers to sections in a book  (Read 310 times)

0 Members and 2 Guests are viewing this topic.

markem

  • Jr. Member
  • **
  • Posts: 58
Assigning numbers to sections in a book
« on: February 22, 2024, 02:05:06 PM »
Hi! Mark Manning here. STILL using Visio 2003.

I know "Ugh!" is everyone's first reaction. However, I actually got someone else to buy a copy of Visio 2003 and they are loving it. So maybe Visio 2003 is not yet dead. :-)

Anyway, what I am doing is I am writing a book IN Visio 2003. Why? Because I know it pretty well and I love the fact that whatever I did the software is not going to try to change it or correct something the program thinks should be fixed and so on. So what's my problem?

Problem. I am putting everything in - in a KIND-OF outline format. But instead of using numbers, presently I'm just putting "X" or "X.1", "X.2", and so on. What I'd like to do is to have Visio 2003 automatically change those "X" parts to be a number. Ok, so now you are going "Why don't you just do this to begin with?" The answer is - parts of the book are still moving around. So today "Gobbledy-Gook" is on page three but tomorrow I might move it to page sixteen. (And believe me - I have moved a lot of the pages around.)

So the question is - is there a way to make these numbers to change automatically when I move a page? (Like the Reference page has moved forty or fifty times.) You know - like the original set up could have been 1-2-3-4-5 but tomorrow it might be 1-3-5-4-2. Could Visio then change all of the numbers back to 1-2-3-4-5?

Thanks for any info or ideas you might have on this.

Yacine

  • Hero Member
  • *****
  • Posts: 3246
Re: Assigning numbers to sections in a book
« Reply #1 on: February 23, 2024, 03:59:17 AM »
Began working on the idea of using list containers, but got stuck when I tried nesting them one in another. Somehow feasible, but cumbersome.
Did anyone experiment with this nesting?
Yacine

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4887
  • Ideas Visio-lized into solutions
Re: Assigning numbers to sections in a book
« Reply #2 on: February 23, 2024, 03:54:16 PM »
@Yacine:  Not I.
@OP:  This ought to work, and doesn't involve code...shapesheet only!   :) :)

Open shapesheet of your shape, and add User Section if not there.  In the user section, you will need to have a separate row for each off page reference that you need.  Then, in each row, (rename as desired), enter a formula with this syntax:  =Pages[Page-6]!ThePage!PAGENUMBER(), except change the 'Page-6" to the current page you want to reference.  Repeat for however many such references are used.

Next, in your example, replace the"X" with field insert reference to the desired User.row.  If you move Page-6, in my above example, say to page 2, the formula automatically updates and tracks.  You may move pages around and re-sequence as desired.

See attached example. 
Visio 2019 Pro

markem

  • Jr. Member
  • **
  • Posts: 58
Re: Assigning numbers to sections in a book
« Reply #3 on: February 24, 2024, 06:06:32 PM »
Thanks Wapperdude and Yacine!

As I feared - I did not state my request clearly enough. But a really neat idea Wapperdude. Maybe I can use the idea - don't know - have to try it. :-)

Ok, let me slightly restate what I was trying to ask.

I am writing a book. In this book there are chapters. I am labeling each chapter as just "X." and so on. So like:

X.0 Introduction
   blah-blah-blah

X. History
   blah-blah-blah

And so on. These chapters (or what I called "sections" before) may span an entire column or maybe a page or even multiple pages. What I'd like to do is to make it so I can go in and remove the "X." part and replace it with a number (so like 1. or 2. or however many there are).

I have tried a lot of different things. None of them worked but I have also been reading the Microsoft manual on Visio 2003. It looks like what I would have to do is to also read the text first, find where each "X." was located, change that to have numbers (updated properly) and then put it back into the object. (All text areas are contained within rectangular areas.)

So after reading fifty or so many pages of information I think this would be done a lot more easily if I just made the changes by hand. So that is what I am doing. I just went back to writing the book and just putting in "X." for each chapter which I can then go back and just change by hand.

Currently I am inserting everything I can find on Mohs Hardness ratings. I've got all of the gems in the world and their hardness ratings. Next will be Mohs Hardness ratings for all of the different types of wood there is in the world, and so forth.

In doing the hardness ratings for gems I am now using Excel to build the tables and am importing them into Visio. I have run into a lot of the drawbacks doing this causes. Like too small column sizes, losing such things as borders, font size, and so forth. I had to fight with Visio 2003 as well as the Excel object and I've pretty much won that battle. So now everything is working well. :-)

Anyway - thanks for looking and making suggestions. Especially thank you Wapperdude. As I said, I'll give that a try! :-)


wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4887
  • Ideas Visio-lized into solutions
Re: Assigning numbers to sections in a book
« Reply #4 on: February 25, 2024, 01:41:04 AM »
Ah!  Sorry I misunderstood.   So, a couple additional questions.
1)  is the format always X.something, or can it vary number of X's, e.g., XX.something.
2) changing the .something is not part of the task
3) is the conversion value  X=>#, predictable?  Presumably not, as sections seen to get moved about and shifted as your research progrsses
4) might there be instances where a section is inserted, necessitating re-sequencing of subsequent sections?  Seems likely..
5) are there links within a section to other section, subsections?

« Last Edit: February 25, 2024, 12:28:03 PM by wapperdude »
Visio 2019 Pro

Yacine

  • Hero Member
  • *****
  • Posts: 3246
Re: Assigning numbers to sections in a book
« Reply #5 on: February 25, 2024, 05:52:21 AM »
A very interesting project!
Let me summarize it the way I understood it.

You use Visio, because you can, in a first step, collect freely chunks of information, place and order them visually as needed. In a second step – and that is the one you’re struggling with – you need to organize and order them in a structure, using tags.

That looks so far very legit – if there weren’t those ugly “x.n” tags in the text chunks, that will need to be converted to actual “smart” tags. You could do it by hand, but you wouldn’t have asked for help if you weren’t hoping for a smarter way to do it.

Our first task would be to identify the information chunks, the shapes. It could be that your visio document contains other shapes that are not relevant to the book structure (Explanatory arrows, frames, etc.). To do so, a macro would add a user field – e.g. “dataText” to the shapes you marked as such. This will make it easier to iterate later over the collection of data shapes.

Then we need to think about how and where the structuring information – the tag – is stored in each shape.
A trivial approach would be to use a prop field. Extract by macro the tag from the text, having a clear separation of content from structure. This step may be superfluous if we can access the tag otherwise by an easy operation.
To explain, if the tag is always at the beginning of your text and separated from it by a line break or a tab, then a simple shapesheet function could identify it.
  x.1
  My title
  My content so and so.
Or
  x.1-->My title
  My content so and so.

The tag having been identified; it is now easy to manipulate it.

To recap, we identify the tag, leave it in the text or move it to a prop field, then we edit it.

Your question would have been answered to this point.

But the story doesn’t end here.
Two things:
1.   Elaborate on the idea of using Visio to structure your document.
2.   Export the content into a format that can be handled by the publishing and production professionals.

Structuring
Different scenarios.
a.   You rely solely on the tags to represent the structure. You would use a macro to collect the chunks, display them in a tree structure (treeview control or idented text) and edit it in a form – that is moving them to other parents, or up and down in a structure. You would not reposition the shapes, only re-tag them. Only in the export step the structure would become visible.
b.   You use Visio’s graphical capabilities to build up the structure.
  i.   By placing manually the shapes both vertically and horizontally to represent a tree
  ii.   By using the tags to place them automatically in a tree arrangement
  iii.   By using connectors – maybe numbered – to implement the structure.
The macro would then re-tag the chunks according to the coordinates (or connections). The macro would also iterate over the pages to collect items belonging to a same chapter and move them.
« Last Edit: February 25, 2024, 06:04:36 AM by Yacine »
Yacine

Yacine

  • Hero Member
  • *****
  • Posts: 3246
Re: Assigning numbers to sections in a book
« Reply #6 on: February 25, 2024, 05:52:44 AM »
Export
That is a huge field. So many technologies, none ideal.
Let me enumerate some that I know.

You would iterate over the shapes of your document, read their text and tag and do “something”.

Target file format
Writing directly in a target file will imply that your routine has already sorted the data entries and that you can write them in the file as they appear in your structure.
1)   MS Word
The process involves creating a Word document in memory, inserting the information and assigning styles (headers, numbering, indentation).
Working directly in Word makes it also easier to handle images and OLE objects (Excel sheets).
Caveat, you need to dive in Word’s object model. Test an inserting and formatting operation, record it, generalize it to a function. Quite cumbersome.
Big advantage only one technology used. Once done you have your final document.
Additional caveat, that formatting stuff is hardwired in the export routine. Bad maintenance.

2)   Markdown + CSV + external resources for the images
Much easier.
You still need a file to write to. That could be a Word file, that you save as text, or a stream that you finally save to disc. I would opt for Word.
The advantage is the ease of use of tags to format the document. No direct tags, just “#” for header 1, “##” for header 2. “*” for bold. “- “ for a list. “1. “ for a numbered list. You get the idea. No handling of runs like you do in Word. No complicated syntax.
Images are a problem, since they cannot be inserted directly. Your routine would need to export them and you would insert the link to the image in your Markdown file.
Similarly Excel sheets would either be exported to excel or converted to CSV or to Markdown table.

3)   HTML + CSS
This is probably my favorite. Easy syntax and the widest feature collection.
HTML tags are more complicated than Markdown, but way easier than Word.
Use CSS classes to format the document.
Convert Excel sheets to HTML tables.
Convert images to base64 strings. They can be stored in the HTML document. No external file.
And CSS can be formatted for printing, with proper headers, footers, margins, page numbers and what ever you might think of.

4)   Latex
Latex is the “right” tool for writing books. But I haven’t yet found the courage to really dive in it. To complicated. Certainly feasible, but not for me.

5)   Pandoc
Last but not least, Pandoc is an opensource text document conversion tool. Not from every format to every other one, but almost. That means that whatever export format you choose, there possibilities to convert to another one.


Used language
1)   VBA
The obvious solution. Available within Visio.
2)   Python
A very fast alternative. I swear by it, but something new to learn.
3)   .Net
The second standard alternative for Visio.


Intermediate platform
1)   MS Access
That is neat.
Caveat, not a standard program in the office suite.
Pro, you export – using onboard features, or self-written routines your data to an Access DB, then using queries and reports, you build up your document and use different export formats. You may also print the report as is and you’re done.
2)   XML
Yes, but no. I don’t like it. Ratio advantage to effort too small.
3)   JSON / YAML
Basically the same as XML, but easier to code.


Puhh, the summary of the last decade of playing with Visio, Access and Word. I hope this is not too much. Let me know what you think about it. We can certainly build something nice.

« Last Edit: February 26, 2024, 04:32:47 AM by Yacine »
Yacine

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4887
  • Ideas Visio-lized into solutions
Re: Assigning numbers to sections in a book
« Reply #7 on: February 25, 2024, 12:37:03 PM »
Covering all bases, in addition to Yacine cooment, observation, and approach options, there are software logs options that can help automate your document structure and dissemination.  These might be worth exploring in the context of a global, company wide development.   And, for those who neither like to think nor invest much effort, there AI.
« Last Edit: February 26, 2024, 01:38:38 PM by wapperdude »
Visio 2019 Pro

Yacine

  • Hero Member
  • *****
  • Posts: 3246
Re: Assigning numbers to sections in a book
« Reply #8 on: February 26, 2024, 04:30:22 AM »
@Wapperdude, this AI approach is very tempting. I read that you can set up a local chat robot. But haven't tried it myself.
Certainly something that we will encounter more and more in future.
When you speak about software logs, did you have something specific in mind?
Yacine

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4887
  • Ideas Visio-lized into solutions
Re: Assigning numbers to sections in a book
« Reply #9 on: February 26, 2024, 11:36:24 AM »
@Yacine:  re, software options.  Nothing specific.  No experience with same either.  (A few years back, I was responsible for newly installed church sound system.  Part of my task was documentation.  Used Visio to create 150 page document with table of contents.  I had a vision of final doc, wanted TOC to update if pages moved, inserted,  or deleted.  Thus, I had preconceived idea how to define the shapes to facilitate a structured document. The document included text, pics, and Excel tables.  Final version published as pdf.)

Having gone thru that process, it occurred to me that businesses must do that sort of thing a lot.  Plus, for conglomerate entities, there's probably some uniformity.  Sure enough.  Googling does have an array of candidates.  For a 1-off scenario, like mine, probably not cost effective.  So, that lead to next evolution in this process...AI.  Creating reports and documents is one of the touted features. 

I suspect the OP could start over, using AI, and have a very quick and very robust soultion.   However, it is an "easy" solution requiring little user skill, and virtually no intellectual growth experience. 
« Last Edit: February 26, 2024, 11:39:48 AM by wapperdude »
Visio 2019 Pro

Yacine

  • Hero Member
  • *****
  • Posts: 3246
Re: Assigning numbers to sections in a book
« Reply #10 on: February 26, 2024, 11:56:34 AM »
@Wapperdude,
1. Interesting that you too created a text document using Visio.
2. I suspect that most businesses start from scratch. The task is probably too often underestimated, so no professionals get involved and "dabblers" like us re-invent the wheel.
3. AI easy? I don't know. If you mean typing a question into ChatGPT, then yes. But setting up and training your own AI, seems to me like a complicated job.
« Last Edit: February 26, 2024, 12:02:08 PM by Yacine »
Yacine

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4887
  • Ideas Visio-lized into solutions
Re: Assigning numbers to sections in a book
« Reply #11 on: February 26, 2024, 01:31:28 PM »
I'm not the only one on forum as evidenced by posts re TOC, Table of Contents.  The aforementioned document, in pdf form, is 17MB.  Not exactly post-able.
Visio 2019 Pro

Yacine

  • Hero Member
  • *****
  • Posts: 3246
Re: Assigning numbers to sections in a book
« Reply #12 on: February 27, 2024, 09:55:28 AM »
I worked some more on the idea and now think that I over complicated it. This project is still interesting, but the answer to your question is very simple.
Not sure if it works in V2003, but it should.
Do a simple "replace" operation.
find what: x.
replace by: y.
Make sure not to select "whole word only". Choose to search in all or only the current page and you're done.
Yacine