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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 363
  • Last Modified:

Capturing 20-30 defined segments of formatted MS Word text as separate VBA variables

I have an authoring application in MS Visio, which outputs data in JSON format to drive a web-based application. Visio was chosen as a development tool because intelligent shapes greatly reduce expert authoring time and reduce authoring errors. However, there is a substantial section of entry-level authoring which simply involves typing formatted text and numerals into 20-30 visio Shapes, each of which gathers data for a separate JSON content field.

I am considering removing this entry-level authoring layer out of the Visio application, and having the text and numerals entering into fields in a more widely available and less expensive application, such as MS Word or an Office form. As a result the entry level authoring would be cheaper and easier.

I ask whether there is a practicable way of capturing text (some of which is multi-paragraph) from defined 'fields' in a word document, and converting each to a public variable, or dictionary item, in VBA. Then I can 'suck it up' into the visio application.

A key issue is the formatting of the entered text. Currently an expert author carries out typical microsoft WYSIWYG text formatting in Visio. The format of text in each shape is defined by format code in each Shape's shapesheet. VBA converts thisVISIO text  into the HTML that is required for the JSON output to send to the web-based app.

One additional complication is that It would also be necessary for the Word-derived text variables to be displayed in Visio shapes: this to meet layout requirement in the visio authoring app.
I do know that the format of text written in Word can be copied and pasted into Visio shapes, without loss or change of format. So I feel there must be a common formatting system at work in both applications.

My questions are:
1. Can I use MS Word as an intelligent 'form' to receive data in effectively 20-30 'fields' (a few of which with be multi-paragraph text.
2. Can that text be stored as VBA public variables (eg in dictionaries) which can be shared with the Visio app.
3. If this is a go-er, how is text formatting data managed in Word and transmitted in data strings?

This is a preliminary question, seeking a practical way forward and advice on avoiding bad strategies (possibly including the above?). If you could point me in the right direction via urls etc, I'd hope to wise up and think further.

PS: from what I understand, MS SharePoint cannot be used for the entry level author to type text into visio fields on a web-based view of a visio diagram.

Thanks
Kelvin4
0
Kelvin4
Asked:
Kelvin4
  • 3
  • 2
1 Solution
 
GrahamSkanCommented:
1. It is possible to designate, e.g. by bookmarks,  particular blocks in a Word document.
2. They can be held as VBA variables, as Strings if formatting is not to be included or as Ranges, if formatting is relevant
3. You would probably have to use an external format, such as HTML, RTF or XML if the formatting is to be understood outside of Word.
0
 
GrahamSkanCommented:
Note that copying and pasting looks like the proverbial duck gliding across the water. There is a lot of paddling going on under the surface.
0
 
Kelvin4Author Commented:
Graham: thank you.  Just like to check through my understanding of point 1...

1. Bookmarks, I set these from the fluent toolbar, enumerate them via vba, and work up an understanding of the representation of my pages of data fields.

Point 3. "You would probably have to use an external format, such as HTML, RTF or XML if the formatting is to be understood outside of Word".  
Here I'm unsure what is meant by using an external format, and I'd like to avoid XML for now becuase of lead time and inexperience with it.  I dont see a way of saving Word 2010 files as HTML or RTF, though there seems to be a method for RTF, since technet says:

"RTF file format     The RTF file format is no longer enhanced to include new features and functionality. Features and functionality that are new to Word 2010 and future versions of Word are lost when they are saved in RTF. In addition, Word 2010 supports a new converter interface based on Open XML Formats."

I only seek basic formatting controls, nothing at all new, but how do I save as RTF - or is something else required.

Please could you lead me a bit further here, as I've run out of clues.

Thanks
Kelvin




0
 
GrahamSkanCommented:
Yes, you select the text that you want to bookmark, and use the ribbon or tool bar (in older Word versions) to insert a bookmark.

Unless you are using any of the new features (e.g. content controls), any save format will preserve the content. Incidentally the default save format is zipped XML.

Actually, I'm not sure if the save format is relevant. I was supposing that you would need to work on saved files as opposed to using the Word Object model on an open document. As I understand it, JSON is based on JavaScript, so it would make sense to try to work with an HTML save

0
 
Kelvin4Author Commented:
It helped me get started, which is what I asked for. The formatting issue is not trivial one suspects.
Thanks!
Kelvin
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now