Finding text in a document - vba

I have documents in which I need to find the text "MM" followed by three integers and compile that into a list. Each document has different sets of numbers, but it always follows this format.
Can I utilize a MS-Word VBA code to do something like this? If so... how?

I think i have just the thing for you to highlight these patterns without macros or coding required.
use the find and replace dialog in WORD and configure it like so:
The magic is this expression:
<MM[0-9]{3}>
see more syntax here:
http://www.gmayor.com/replace_using_wildcards.htm
I did it here in Word 2010 and it works perfectly.
picks up
MM123
MM232
and skips
MM2f1
MM2323
Edit: if you're trying to compile it into a separate list in addition to highlighting it in the doc, I'd suggest you save a copy of the doc as a plaintext file, then write a really simple shell script or console application to grab the strings you're looking for.

do you know regular expressions? (also called regex)?
This is a way to perform searches based on varying search patterns. Very easy, as you just need to use your usual search window. Just change the search pattern according to some rules. An introduction for regex in Word is available here:
http://www.svprogramming.net/regent/documentation/Microsoft-Word-Wildcards-as-Regular-Expressions.html
Good luck!

Related

batch convert weblinks by appending characters

is there any easy way to batch convert links by appending characters and provide batch output.
As shown in this picture
https://i.imgur.com/resTpFQ.png
The inputs will be given in batch as separate lines , and the output expected is batch in separate lines..
I do not have any programming background, so appreciate if you can direct me to any application that can easily do it without me writing the code else you can give me advice. I do have windows and MS office, so if there is something already in there, that can do it by writing a simple program, also let me know.
You can use regular expressions to achieve that. There are many online tools where you can transform your data without having tools installed locally.
I prepared an expression for you here: https://regex101.com/r/l1ZUHZ/1
Programmatically a solution could look like:
/^(http.*)/![]($1)/gm
A second example, that matches the protocol and replaces it with https: https://regex101.com/r/sufiUI/1
/^https?(:.*)/![](https$1)/gm
Sorting is a different task. I suppose you can do that in Excel for example. There's also a sort command available in Windows.
To sort in reverse order you need the /r option.

syntax editor - how to write dynamic language xml definition file?

So I want to create my own programming language in vb.net 2013 and I see SyntaxEditor by actipro software fits, but how do I write xml definition file that tells which words how to be colored? is there a tutorial somewhere?
Also, how do I make the syntax editor to display the number of the line?
SCREENSHOOT OF MY PROGRAM
Showing the line number is just a property of the SyntaxEditor-control: in WPF-version it is "IsLineNumberMarginVisible". you have to set it to "true". I assume the property in WinForms-version has the same name.
when you install Actipro then there are a lot of samples included. Just look for files named *.langdef and you will find a lot of files where you can see how they shall look like.
There is also a tool "LanguageDesigner.exe" delivered with SyntaxEditor. It gives you a nice UI to create and edit the language file.
Generally I recommend to take a look at the sample projects, specially the SampleBrowser-Project with the "GettingStarted01" to "GettingStarted15" controls.

Select three rows of text in PDF using VBA

I am trying to use VBA to select three rows of data in a PDF file and copy them to the clipboard. I have tried third party libraries but I still can't seem to find a simple solution. I can use the cursor to select the data and copy it, so I just want to automate this step with VBA.
I have looked high and low for an answer to this and I feel like it might be really simple and I'm just missing it. I assume I could just use the "highliteList" method in the acrobat library to select the rows, but I don't know how to specify where to begin the selection. There is a header on each page, so I just want to say something like:
For Each header In pdf.pages
NextLine.SelectRow
NextLine.SelectRow
Next header
Selection.CopyToClipboard
Is this possible? I know those methods probly don't exist, I was using it as an example. Does anyone have experience with doing this? Thanks in advance for any help
I found a solution for all those interested. I used Bytescout PDF extractor library to convert the file to .xls format. Then I just parsed out what I needed in Excel since Excel is easy to work with via vb.net.

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.

Outlook Search Folder Criteria

Is it possible to set criteria of a Search Folder in Outlook to a large number of keywords, like this:
subject contains "abc" OR "def" OR "ghi" ...
Search for the word(s) box in Search Folder Criteria does support comma-separated list of values, but the max. length of that box is quite limited (255 chars I guess). The number of keywords I have is very large (hundreds of them). Adding them manually through Advanced tab is also a pain, so I'm looking for a more programmer's way. One of the following should work:
If Outlook stores these criteria in a flat file somewhere (like Thunderbird does), I'll edit it directly and inject my keywords into it.
If I could manipulate the criteria through Object Model (VBA), that's also a good solution.
If VSTO can do it, I have that experience as well.
Does someone know if any of the above method works?
Note: I'm using Outlook 2013 if that has something to do.
You can develop either a VBA macro or an Outlook add-in (VSTO can be used for developing an add-in). Try using the AdvancedSearch method of the Application class. See Advanced search in Outlook programmatically: C#, VB.NET for more information.