Showing posts with label ITServices. Show all posts
Showing posts with label ITServices. Show all posts

Monday, November 2, 2009

Find and sort acronyms for Microsoft Word document automatically.

We guys work on Information Technology. I always have too many acronyms to deal with when I create a document.  There are many solutions of adding acronym to a word document, such as add as a Bookmark or Hyperlink. But most of them require the author to go through the document and mark all the acronyms manually, which I don’t like.

This script searches through your word document and find all Words >= 3 (configurable) alphabets in Uppercase, then remove duplicate entries and sort by alphabetical order.  This is exactly what I need.  If  you want to try, click Tools->macros->Visual Basic Editor, copy-paste the code below and execute it. There you go!

 

Sub ExtractAcronymsToANewDocument()

Dim oDoc_Source As Document
Dim oDoc_Target As Document
Dim strListSep  As String
Dim strAcronym  As String
Dim oTable      As Table
Dim oRange      As Range

Dim n As Long
Dim strAllFound As String
'use to keep track of founded. Find the list separator from international settings
'In some countries it is comma, in other semicolon

strListSep = Application.International(wdListSeparator)
strAllFound = "#"

Set oDoc_Source = ActiveDocument
'Create new document for acronyms
Set oDoc_Target = Documents.Add

With oDoc_Target
'Make sure document is empty
.Range = ""
'Insert a table with room for acronym and definition
Set oTable = .Tables.Add(Range:=.Range, NumRows:=2, NumColumns:=3)
    With oTable
    'Format the table a bit
    'Insert headings
    .Cell(1, 1).Range.Text = "Acronym"
    .Cell(1, 2).Range.Text = "Definition"
    .Cell(1, 3).Range.Text = "Page"
    'Set row as heading row
    .Rows(1).HeadingFormat = True
    .Rows(1).Range.Font.Bold = True
    .PreferredWidthType = wdPreferredWidthPercent
    .Columns(1).PreferredWidth = 20
    .Columns(2).PreferredWidth = 70
    .Columns(3).PreferredWidth = 10
    End With
End With

With oDoc_Source
Set oRange = .Range
n = 1 'used to count below

    With oRange.Find
    .Text = "<[A-Z]{3" & strListSep & "}>"
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchCase = True
    .MatchWildcards = True
    Do While .Execute
    'Continue while found
    strAcronym = oRange
    'Insert in target doc
    'If strAcronym is already in strAllFound, do not add again
    If InStr(1, strAllFound, "#" & strAcronym & "#") = 0 Then
        'Add new row in table from second acronym
        If n > 1 Then oTable.Rows.Add
        'Was not found before
        strAllFound = strAllFound & strAcronym & "#"
        'Insert in column 1 in oTable
        'Compensate for heading row
        With oTable
        .Cell(n + 1, 1).Range.Text = strAcronym
        'Insert page number in column 3
        .Cell(n + 1, 3).Range.Text = oRange.Information(wdActiveEndPageNumber)
        End With
        n = n + 1
        End If
        'If acronym
    Loop
    End With
End With

'Sort the acronyms alphabetically
With Selection
    .Sort ExcludeHeader:=True, FieldNumber:="Column 1", SortFieldType _
    :=wdSortFieldAlphanumeric, SortOrder:=wdSortOrderAscending
    .HomeKey (wdStory)
End With

'Clean up
Set oDoc_Source = Nothing
Set oDoc_Target = Nothing
Set oTable = Nothing
MsgBox "Finished extracting " & n - 1 & " acronymn(s) to a new document."

End Sub

Saturday, October 10, 2009

How to make your WindowsOS execute faster?

My Windows XP becomes slower and slower over the time. Therefore, I had to google the internet and look for tools and tricks to optimize my Windows XP as much as possible. However, there fore many so called "Windows optimization tricks" does not work as it specified at the web-page. After several rounds of retry, I listed those steps I think useful for my Windows XP optimization.

1. Remove unnecessary software and components, especially Windows Index services;

    Go to Control Panel-> Add or Remove programs, check those rarely used software, whether it is installed intentionally or unintentionally, then uninstall those you don't need.

    Go to Control Panel-> Add or Remove programs -> Add/Remove Windows Components, remove those components you don't need. For example, Windows indexing service.

    Disable unnecessary start-up items. Google "Windows Startup Manager" will list tools to help on this topic.

2. Delete unnecessary files;

    Many Windows optimization tools offer some utility to clean up the unnecessary files. I am using this one: http://www.ccleaner.com/

    The tool can only delete temp files created by some installation process or Windows application. If you downloaded a file and later forgot it, the tool won't know it. So it is important for you to make your directory structure organized. For me, I create a <Root>/Data directory to store all human created data (versus directory created by installation binaries). I always download any article to <root>/Data/temp first, and only move valuable binary or documents to my permanent directory structure if I think it is useful.

3. Optimizing you Windows appearance

    Go to Control Panel->System->Advanced->performance Settings->Visual Effects, choose Custom and tick:

         Show shadows under menus

         Show translucent selection rectangle

         Smooth edges of screen fonts

         Use drop shadows for icon labels on the desktop

         Use visual styles on windows and buttons

    You may have some other preference, but I found this tick-list is most close to Windows default and what I feel comfortable.

4. Stop unnecessary Windows services:

    Windows starts a lot services by default, most of them are not necessary, so Go to Start->Cmd->services.msc and select Which services you want to stop. However,  many web page on optimization tricks ask you to go through the service one by one and stop a lot services, which maybe harder for novices.  Besides all the default setting, I only changed 3 of them to manual: Remote Registry, Telnet, Indexing Services.

5.  Clean up registry;

     It is dangerous to edit Windows registry (though sometimes I do), better find a tool to do it automatically.

6. Irq14=4096.

    It is said add Irq14=4096 will improve the hard-disk performance. I did so, but not sure whether my hard-disk performance is improved, nor did I figure out the reason. The paper said is increased the buffer for hard-disk read/write, but I did not figure out what is the default buffer setting.

7. De-fragment your hard-disk regularly;

    Find you C: or D: drive at Windows explorer, and click property, use your Windows tool to de-fragment the hard-drive, and reboot it. 

IT Services

Many people came to ask me about some IT configuration questions. This page lists most of my recommendation for configuring PC and SOHO network. It is open for discussion. Please send your comments to jinsheng_tang@yahoo.com

1. Setup your PC.

It is better to setup your PC dualboot with Windows XP and Linux if you are an IT professional or willing to be, otherwise please check the Windows section only.

It is easy to setup your PC with Windows and Linux dualboot, please google "config Windows Linux dualboot" for detailed procedures.

The recommendation here is:

1. Partition your hard disk with 8-10G for Windows OS, which will be used for install of Windows OS and application only.

You may wonder why so much disk space is required, it is reserved for multimedia tools, various Java virtual machines, documentation tools like MS office and Visual studio and Oracle tools.

You may need 2-4G more if you want to play around with Virtual PC, but it is not encouraged as I felt it is very slow and not worth for use. I'd rather use 2 PCs instead of setting up Virtual PC.

If you are not going to play around with Oracle or Java Virtual Machine or Visual Studio, I bet you need several multimedia tools. So reserve 5G at least.

2. Assign 6-8G for Linux

Redhat Linux 9.0 needs nearly 5.0G for a complete installation plus Linux swap and boot, You may want to deselect many language package during installation to save some disk space, or sort RPM by size (please google some perl script to do it) and remove unnecessary RPM with size over 1G. Eventually around 1G space could be saved.

I have encounter the problem that some automatic compile script or Makefile can not be executed at a Linux specific file system (ext2, ext3). So I reserved 3G space for building cross development environment or running big automatic compile script.

3. Leave the rest to store data only and make this partition dual accessible by both Linux and Window OS;

It's better to decide your directory structure and don't change it often even when your computer changed. It's easy for backup and maintenance.

2. Windows

Recommended applications to be installed for Windows OS.

Full set of Microsoft office ;

Adobe Acrobat;

MyIE2 (browser);

Ultraedit;

Antivirus serious;

金山影霸,RealOnePlayer, 暴风影音。

download tools: nettransport, cuteftp,

Quick Screen Capture;

System maintenance: System mechanic or Windows optimizer;

3. Linux

Linux is most installed by IT professionals to investigate, it is still weak for common desktop applications.

I usually use all the default packages for desktop usage.

For office document, use OpenOffice.

If you are a far east user, please refer to http://www.opencjk.org/projects/wineinput/index.html

If you are an IT professional and want to investigate some advance usage, please refer to

a. build a cross development network at Embedded section;

b. Setup SOHO network by Linux.

4. SOHO

Many sales people may approach you to sell their product for you SOHO network. I prefer to use Linux for all of these, although it usually means lack of technical support from suppliers. Actually you could find almost all solutions from internet.

The following configuration are essential for a software development based company.

a. networking. It is recommended to get a dedicated low-end router plus several switch although you could config one Linux machine as the router.

b. Define IP address range, bind your IP address with MAC address so it is easy to manage.

   Always use DNS to assign the IP address.

c. Config IP tables or your router may have some way to have firewall configured;

d. Setup NIS (Yellow Page service) so that all your intranet use can use the same account regardless of where he logged in;

e. Setup quota limit for every user accounte.

f.  Setup a common temp file for all users so that they can exchange huge file even it exceeds the quota limit.

g. Monitor your network if necessary.

h. backup all your data hourly, daily, weekly, monthly.

This page has links to some useful online resources for configuration that I have been used.

They could be used for setting up either desktop environment or embedded development environment.

How to setup J2EE, J2ME for Mobile Applications?

How to run IIS in Windows XP Home Edition?

How to install a Linux Virtual PC?

How to use Chinese in Linux?

How to setup WinCVS with SSH?

How to create a Linux daemon?

How to run XWindows Applications Remotely?

How to use ramdisk for Linux?

How to do DiskOnChip development?

How to config Apache?

How to debug Linux kernel?

How to use cgi-bin?