If you want to automate your find and replace in MS Office Word Document
You could use or modify this Sub to suit your own needs.
Remember it only support upto 512 bytes (512 characters) of text at the time.
Sub FindReplace()
' Find and replace string in document
' Support up to 512 bytes (double size the default)
With Selection.Find
.ClearFormatting
.Text = "old text"
.Replacement.ClearFormatting
.Replacement.Text = "new text"
.Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue
End With
End Sub
Programming
MS-Office, MS-Office-Word, VB-VBA
Sometimes when you need to execute a task every period of time and there's no straight predefined function that you can just call and use with a few lines of codes. You will actually need to implement your own module.
I've written this nice class module sometime ago and I believe it will be useful for other VB/VBA developer out there. This class is an Auto Executor, it will automatically call and run a defined Routine.
It will solve the problem in the scenario above and it is written in an object oriented style which you can just embedded the whole class in your project and when you need to use it, just create the instance of it then call the public sub routine to perform the task.
Read more...
Programming
Auto-Timer, Time-Interval, VB-VBA
This article is for VBA developer. I've written this class to save my work in the future when I have to deal with data I/O. Hopefully it will be useful for you as well.
This class can be used as part of your VBA project. It enables the flexibility and control the format of data.
The main functionality is for data Input/Output. eg. Save/Write data to/from file. It is using Microsoft XML, v3.0 which should compatible with MS Office 2000 onward.
NOTE: This class module is not working with non-default UserForm Controls, you will need to modify it so it will recognise your Controls type
Features
- Output Form data to a well-formed XML file format
- Load data from XML file to Form and intelligently place data to correct field without deveoper interaction, and work seamlessly across any UserForm
- Check version compatibility between Data file and Form
- Run on Backup mode can be disabled/enabled on demand
- Purge Unused files can be disabled/enabled on demand or make direct Call
- Option to Delete file to Recycle bin. This will prevent accidental delete
Read more...
Programming
VB-VBA
Spell Checking in MS Word can be automated by adding a few line of code behind your word document.
Code below can be used in your VBA project. It works in Word, and it should work in Excel as well but I haven't try it. If you encountered any problem using it in any other VBA project, post your comment here, I'll have a look at it.
Sub RunSpellCheck()
' Run Spell Check
If MsgBox("Do Spell Check now ?", vbYesNo) = vbYes Then
ActiveDocument.Content.Select
Selection.WholeStory
Selection.LanguageID = wdEnglishAUS
ActiveDocument.CheckSpelling
End If
End Sub
Programming
Spell-Check, VB-VBA
In VBA programming, it's time consuming when it come to checking and validating the data entry, specially those fields that are mandatory. You might have to write hundreds lines of code (depends on how big your form is) to handle such incident. You might feel like, if there's should be something "Mandatory Checker" to handle this part of development. The new .NET framework included this feature in Application Development environment but unfortunately they did not include it in VBA.
I though I would spend sometime to write this class (MandatoryChecker) and reuse it in the future development when needed. So if you are a VBA programmer, I presume this will help you quite well and save you time validating the mandatory field entry on the form.
Read more...
Programming
VB-VBA