How can I change multiple word files' attribute as 'Read Only Recommended' - vba

I have a daily word which I need to change around 100 word files as 'read-only-recommended' before sending to client.
I cannot figure out a VBA solution to do that, could you give me a hint? Thanks and regards.

There is a Microsoft Community Answers Forum article entitled Batch Editing MS Word Documents that you should read. It provides VBA code for both Windows and Mac versions of Office. In the article's supplied code, there are two locations marked with:
This is where you will insert your code for applying the edits you
want to perform
You would insert:
ActiveDocument.ReadOnlyRecommended = True

Related

Easiest way to add raw Open XML code to a Word document

I want to insert a chunk of formatted text into a Word document in VBA. Since this will be done server-side, I am not advised take these chunks from another Word document using Office Interop (link), so I presume it would be easiest to use Open XML like this <w:p><w:r><w:t>String from WriteToWordDoc method.</w:t></w:r></w:p> Sadly Application.ActiveDocument.Range.InsertXML fails. So what other quick and dirty alternatives do I have?
For the "bare necessities" see this MSDN article:
https://msdn.microsoft.com/en-us/library/office/dn423225.aspx?f=255&MSPPError=-2147217396
It describes what the minimum requirements are for inserting Open XML into an open Word document. Don't worry that the discussion targets Web add-ins - the principle is the same for any API that inserts WordOpenXML into a Word document at run-time.
I may be misunderstanding where "server-side" is involved in your process, so forgive me if the following is not relevant to your situation: Note that using VBA server-side is a bad idea - Word is not designed to run in a server environment. Better would be to use the Open XML SDK both to retrieve and write the information between two Word documents.

Word - Is it possible to change easily all links' source in a document?

I have 5 Word template linked to an Excel file to automatically generate new pre-formated reports.
As I am working on improving it, I have created copies that will replace the old version once I'm done. And in each template, I have approximately 70 links, so almost 350 links in total.
My question is :
Is there a way to change easily the source file for multiple links?
Solutions with or without code are welcome!
Is it possible? Yes
How? A Google search reveals multiple options with lots of code to copy/paste.

Automated Excel document creation using VBA

The managing director at our company wants me to produce an automated monthly document that saves to a certain place on our system so that he doesn't have to manually input all of the data. I have set up so that the document can save to the correct place in the correct format but my knowledge of VBA is not great.
Tackling this from a 1 question at a time point of view I suppose my question would be is it possible to create 1 very long macro that will accomplish many different tasks over several workbooks. For example we have a report that comes from our ERP (Baan) and shoves all of the data into one cell. Is it possible to create a macro that will accomplish formatting text to columns, then copy data from a cell based on a row reference and then take said data and paste it in to a different workbook? Would it then be able to save the workbook all from just running one macro and if so how long will all of that take once the macro is executed?
Yes I believe this should be do-able, keeping in mind that the file names + location remain the same (otherwise you'll have to edit each month). Create different Subs/Functions and call them in one main macro.
The easiest way is probably to do it step by step. Record macro's and see whether that already helps you out and if not use google & stackoverflow for help! :)
it is entirely possible - but in my Opinion VBA is not well suited to the task. The editor is atrocius at best and it is easy to produce highly specific "spaghetti code".
File operatione are possible, but are not nice. Error handling is 80s style with lots of goto.
So if you want to build something maintainable, build an external Application using Interop or epplus (.net package for reading /writing to excel documents) or an .net addin for office.

Storing arbitrary meta-data in Microsoft Word document

I need to store custom meta-data in a Word document. The 'document properties' are limited to 255 bytes but I have data which is >> 10k
We are using VBA to write a word extension to interact with our application and want to have our application data stored in the word document. The idea is that that the user can share just the word document without sharing any other data files of our application.
Has anyone ideas how to store arbitrary meta-data efficently in Office 2003+ documents?
Just tried this in the VBA editor immediate window:
ActiveDocument.Variables.Add "foo", String(10000, ".")
? Len(ActiveDocument.Variables("foo"))
10000
Document variables are stored with the document. They seem to go up to 65280 Unicode characters, as I just found out (tested in Word 2003; Update: This limit is the same in Word 2007 and 2010).
If you fear to get near the 60k for your data, I'd recommend either splitting it over several variables, or compressing it before you store it. This post shows some options to do that in VBA.
It fits not exactly your requirements because it does not work with Word 2003. However, it still might be interesting to you (otherwise I recommend you to use document variables as suggested by Tomalak):
In Word 2007 (and later) you may embed arbitrary XML documents in a Word document as Custom XML.
An example is described ins this article on MSDN: How to: Add Custom XML Parts to Documents by Using VSTO Add-Ins

How do you print your programs to MS Word?

We have a project, and the professor asked us to print the program codes using microsoft word. however when i pasted all my codes in ms word it turns out that it doesn't have coloring, those nice programming fonts.. It just looks awfully ugly in microsoft word..
I want this to be printed on papers very gorgeously. Like what we see in our notepad++
If you are on Windows, you can open the source code in Visual Studio (assuming it is C++, C# or VB), copy the code, and paste it to Word.
"Visual Studio" to "Word" does keep the formatting (color and fonts).
I do not use Word for this when I can avoid it. It's simply not very good at keeping the formatting and doesn't provide really good-looking prints.
The line-breaking isn't program-aware.
The paragraph breaking isn't program aware.
The keeping of the formatting from VS doesn't do structure-based markup, does it?
The typesetting engine of Word is a lot worse than TeX or Quark/Indesign
Microsoft Word is very handy for code reviews. Particularly if you don't want to splurge for one of the tools explicitly designed for peer code reviews. Each reviewer can insert their comments and/or modify the code themselves right in the document. If you keep track changes on then you can see what was changed and accept or reject the changes. During the review you only have to cycle through the comments and changes. When you are all done, you can simply copy and paste the final product back into the source file. It beats having to take a list of comments, decipher them and then incorporate the requests yourself.
EDIT: We use Visual Studio. So Cut/Paste between the source and Microsoft Word works fine, except in the cases where the line length exceeds the page size.
If you have the NppExport Plugin, go to
Plugins -> NppExport -> (Then you can choose between "Export to RTF", "Copy RTF to Clipboard", or "Copy all formats to clipboard")
Then open it in Microsoft Word if you choose export to rtf, or paste it to Word if you choose copy to clipboard
Hope this helps
I tried it for my SQL assignment and it works
I'm not sure I understand the question, but if you're asking "how do I put my source code into Word and make it look pretty like Notepad++," you'll want to do some research into automating Microsoft Word.
Word automation using C#
OLE Automation using Word (Article)
Microsoft Word Automation Class
This may seem obvious, but how about you just print it from notepad++?
Eclipse does the same thing told by decasteljau.
When you copy code from eclipse, and then you paste on Outlook, the code keeps its colours.