Is it possible to have a treeview in Microsoft Word with VBA? - vba

I was looking at software to write novels and stories and they have basically the same organizational format. They have a tree on the side and folders for organizing. Here are some examples:
http://storyist.com/assets/screenshots/StoryistCollage-Full.jpg
http://www.literatureandlatte.com/scrivener_pages/screenshotcommentary.php
I have Microsoft Word and being a programmer (among other things), I wondered if there is a way to use VBA controls and create this look and organizational process in Word.
Is there any way to do that? If there is, how would I begin? Or, is this something I need to do standalone?
EDIT: Here is what I am looking for:
http://writingoutliner.com/software-features/project-based-writing-for-long-documents.php
Is this possible solely with VBA?

Your question if broken down would be something like this
I wondered if there is a way to use VBA controls and create this look and organizational process in Word
Is there any way to do that? If there is, how would I begin?
Is this something I need to do standalone?
Unfortunately Word would be a wrong choice if you want that kind of professional Look. If you want a standalone I would recommend creating a CHM (Compiled Help Modules) file. It would look something like one of your Windows Help File.
There are many free software's that can create CHM Files for you. One such link is here.
If you want a really amazing tool (I use the same and unfortunately it is not free) then check out Help and Manual 6
If you still want to do it in word, you will have to use VBA and then use the Treeview Control in a userform. The biggest disadvantage of Treeview is that it is not distributable. To see how to work with Treeview control, see my other reply here.

Related

How can I expose Word VBA macro code as text files in VSC to better commit and track code changes?

Background and Problem
I lead a team of tech writers. Our team has a Word template (.dotm file) that has a bunch of VBA macros we've created over the years to help us automate tasks in Word. The macros are obviously stored inside of a .dotm template. Given that the code is stored in a binary file, the code is not easily traceable across commits.
Currently, we have to pull the changes on the branch and then open the macro inside Word's embedded code editor from the .dotm. But there's no way to see what exact code changes someone else made line by line or resolve conflicts using something like Beyond Compare.
What I Need
I'd like to find a way to automatically expose the VBA code from the .dotm as some kind of text file so that we can:
Do Word VBA coding tasks within VSC
Easily track and review each others code changes at the line level using our git repository
Resolve merge conflicts more easily
Has anyone found a way to do this?
What I've tried
I've tried searching online and on stackoverflow.
Hoping it might help, I installed ScriptLab, and I after following the MS tutorial, I now have Office Add-Ons working with VSC.
(https://code.visualstudio.com/docs/other/office),
(https://learn.microsoft.com/en-us/office/dev/add-ins/tutorials/word-tutorial) While the Office Add-Ons through VSC does provide an alternate (more modern) way of automating using Javascript, and the .js files are commit-able, it's not providing a way to expose the Word VBA, at least not that I could see.
Thank you in advance!
ScriptLab add-on is for playing with JavaScript code instantly, not designed as a macro infrastructure in Office.
Sounds like you need to switch your VBA macros to COM add-ins rails. There is no converters that can do this part of work for you automatically.
You may consider creating a VB.NET based add-in. In that case you will avoid language translating issues. You may find the Converting Code from VBA to Visual Basic .NET article helpful. It presents issues to consider when converting your Microsoft Office solutions from Visual Basic for Applications (VBA) to Visual Basic .NET. Provides a general overview of their differences, and then uses examples from Word and Excel to describe how you can use Visual Studio Tools for the Microsoft Office System to convert your code.

Rolling out Word Macros to various Users without affecting existing Macros?

Am a complete newbie in Macros and do not find much support in Word macros
I have a macro with New ribbons which needs to be rolled out to various Users without affecting their current macros.
Which is the best possible way to perform the same.
Thanks in advance!!
P.S. Not sure if similar query has already been addressed. Didnt find any conclusive answer yet.
Your code and ribbons need to be in a template (.dotm) located in the startup folder.
On Windows the default location is \Users\<UserName>\AppData\Roaming\Microsoft\Word\STARTUP

Vba Project Guidance

I have a general question and I'm not sure where to begin, literally. Can you please leave any direction at a fairly high level so I have the chance to try to figure it out for myself? Here's my initial plan, but here's the issue! I don't know where to start. Where would I begin with this? Would it be an Excel module? I need some direction guys!! Let me give you a quick run down of what we're trying to accomplish.
We start out with 2-3 customer specific spreadsheets with an account number + [static] file name.xlsx and about 7 generic template excel files where we use the data from the customer specific spreadsheets and save a copy of each of the template files in the customers store folder.
What I'm trying to figure out if VBA is the direction that I need to be going with this or if there is another method that would accomplish the same goal or be more efficient at getting it done. My thinking at this point is open one of the customers files, save the active workbook file path as a string (this would contain the file directory, division, customer number and customer name), split the string of the file path and save the information that I need as variables, open the appropriate template files based on division number, probably run a couple recorded macros then re-save the files using the account number in the appropriate directory. If there's anything else I left out for this to make more sense, please let me know and I'll re-edit the post. Thank you in advance for any guidance!!
I don't think you should use Access or VSTO - I'll explain why, then offer a practical way forward.
Access is way over the top for what you want to do: most people find it much easier to write code in Excel VBA (I speak as a trainer with 20 years of experience, who is a guru on both packages).
Visual Studio Tools for Office was Microsoft's attempt to get the business world to stop using VBA in Excel, and use the much more robust VSTO within Visual Studio. It's a great idea, but unfortunately not many people seem to be adopting it. In computing it's rarely a good idea not to go with the flow (and anyway, the learning curve for VBA is shorter than that for VSTO, IMHO - hope that's enough acronyms in one sentence!).
As to the practical solution: I've just finished writing a fairly large online tutorial in Excel VBA, which is at exactly the level you need, I think.
Good luck!
Since you are dealing with XLSX files then you are in Office 2007 or 2010, so you could use Visual Studio Tools for Office. This will allow you to use the .Net framework and C# or VB.Net in Visual Studio to get a better development experience than VBA. You could add your own ribbon and buttons to Excel to help accomplish your tasks.

Using the Office Interop for Word and Outlook 2007 in VB.NET

I need interop in my programs to automate several functions in Word and Outlook. Does anyone know a good place to start. My goal is to kick off a mail merge, create several different files and save them accordingly, then e-mail the different files to different people based upon who needs what. Any help learning how to use the interop properly would be greatly appreciated.
I am currently using Visual Studio 2008 and Office 2007 and use vb.net to write my programs.
A good way to get started is to use the macro editor to record the steps you are trying to perform. You can take the generated macro code and modify it for your purposes to suit. Click on the names of functions and variables of which you do not know the purpose and hit "F1" to get context specific help.
Add COM references to Outlook 12.0 Object library and Word 12.0 Object library.
This web page really helped kick me off: http://support.microsoft.com/kb/316383
Then, by recording macros you'll expose a lot of the stuff you'll likely want to work with. Word of warning, however, is that not everything exposed in VBA (macros) is accessible within VB .NET. I don't know why this is, but I've actually had to construct and execute a macro from VB.NET, written in VBA, within Excel to accomplish something that seemed ridiculously easy if it weren't for the strange disconnect between the two.
Some good info on Mail Merge: http://support.microsoft.com/kb/258512
Here's an article with some basic steps to get you up and connected with Outlook's Interop: http://support.microsoft.com/kb/313787
Hope this helps. I'll keep an eye out for questions from you here--I'd say I know quite a bit when it comes to interop.
You might want to start here: http://msdn.microsoft.com/en-us/office/bb266408.aspx.
There are a number of tutorials.

How do I embed a custom user-control in MS Word?

Context: The environment is .Net 3.0 + WPF land, the DB is abstracted well out into the distance and the solution would need to work for Office 2000 and up I guess..
The need is to get a customized report for which the user would like to have certain application windows/boxes (e.g. a trend graph) displayed in Word. The window can be shown as a static image, the user can double-click and edit it (that would bring up an editor.. similar to behavior for an embedded spreadsheet) and OK out to update the object. Type some text around the box and save it or print it.
Also take into account, that I would need some mechanism to pass in data and kind of "data-bind" these app-specific boxes to it. e.g. the graph may have to bind to a specific time-range of data that it needs.
Now as a relative beginner to Word automation, what is the name of the tech / sub-tech that I would need to use for this? Also post any recommendations to books/posts that help you understand and get to running speed ASAP.. (since the business always believes the programmers are smart enough to figure it out.. we can give them complete trust.. but no time.)
I think you are going to have to look into writing an OLE embeddable/compatible application. It sounds like this may be a very large and complex task.
Is there any reason that Excel cannot do the graph that you are embedding?
I would strongly recommend making it dependant on Office 2007 and later. If you do so, you can use the ribbon and do .Net programming via VSTO.