posts in category "IT"

September 26, 2012

MF2T_GUI released

MF2T_GUI is a additional GUI for MF2T.
MF2T is a is a tool to convert StandardMIDI format to text format and vice versa, written by Piet van Oostrum.

It is a legacy tool so I’m not sure there are needs, but I need a function to select files with file open dialog and to convert them as batch input.

This is free to use, copy and redistribute.
Hope this will be some help.

Go to DOWNLOAD page.

October 7, 2011

MS Word Drawing Canvas Hack #3

This is a sequel of The topic about MS Word #1 and #2.

I’ve got a request for “Distribute Horizontally” and “Distribute Vertically”.
Then I wrote macros for them.

The code below.
Please refer previous entries about how to manage.

I’ve modified,,,

  • Added Function : DistributeHorizontal, DistributeAlignVertical, SortHorizontal, SortAlignVertical
  • Changed the type of variables : AlignHorizontal, AlignVertical

The algorithm for sorting was selected for its simplicity rather than speed since the number of objects to be distributed is not so large.

Private Sub AlignHorizontal(ARate As Single)
Dim Min, Max, i As Single
    Min = 32768
    Max = -32768
    For Each AShape In Selection.ChildShapeRange
        If Min > AShape.Left Then
            Min = AShape.Left
        End If
        i = AShape.Left + AShape.Width / 20
        If Max < i Then
            Max = i
        End If
    Next AShape
    For Each AShape In Selection.ChildShapeRange
        AShape.Left = Min * (1 - ARate) + Max * ARate - AShape.Width / 20 * ARate
    Next AShape
End Sub

Private Sub AlignVertical(ARate As Single)
Dim Min, Max, i As Single
    Min = 32768
    Max = -32768
    For Each AShape In Selection.ChildShapeRange
        If Min > AShape.Top Then
            Min = AShape.Top
        End If
        i = AShape.Top + AShape.Height / 20
        If Max < i Then
            Max = i
        End If
    Next AShape
    For Each AShape In Selection.ChildShapeRange
        AShape.Top = Min * (1 - ARate) + Max * ARate - AShape.Height / 20 * ARate
    Next AShape
End Sub

Private Sub AlignShape(AHorizontal As Boolean, ARate As Single)
    If Selection.ChildShapeRange.Count = 0 Then
        Exit Sub
    End If
    If AHorizontal Then
        AlignHorizontal (ARate)
    Else
        AlignVertical (ARate)
    End If
End Sub

Sub AlignHorizontalLeft()
    AlignShape True, 0
End Sub

Sub AlignHorizontalCenter()
    AlignShape True, 0.5
End Sub

Sub AlignHorizontalRight()
    AlignShape True, 1
End Sub

Sub AlignVerticalTop()
    AlignShape False, 0
End Sub

Sub AlignVerticalMiddle()
    AlignShape False, 0.5
End Sub

Sub AlignVerticalBottom()
    AlignShape False, 1
End Sub

Private Sub SortHorizontal(ByRef ACol As Collection)
Dim TmpCol    As Collection
Dim l_cls       As Object
Dim l_clsMin    As Object
Dim MinID As Integer
Dim i           As Integer
    Set TmpCol = New Collection
    Do Until (ACol.Count = 0)
        MinID = 1
        For i = 2 To ACol.Count
            If ACol(MinID).Left > ACol(i).Left Then
                MinID = i
            End If
        Next i
        TmpCol.Add ACol(MinID)
        ACol.Remove MinID
    Loop
    Set ACol = TmpCol
End Sub

Private Sub SortVertical(ByRef ACol As Collection)
Dim TmpCol    As Collection
Dim l_cls       As Object
Dim l_clsMin    As Object
Dim MinID As Integer
Dim i           As Integer
    Set TmpCol = New Collection
    Do Until (ACol.Count = 0)
        MinID = 1
        For i = 2 To ACol.Count
            If ACol(MinID).Top > ACol(i).Top Then
                MinID = i
            End If
        Next i
        TmpCol.Add ACol(MinID)
        ACol.Remove MinID
    Loop
    Set ACol = TmpCol
End Sub

Sub DistributeHorizontal()
Dim Min, Max, i, Total, Interval As Single
Dim ShapeCol As Collection
    If Selection.ChildShapeRange.Count > 1 Then
        Min = 32768
        Max = -32768
        Total = 0
        Set ShapeCol = New Collection
        For Each AShape In Selection.ChildShapeRange
            If Min > AShape.Left Then
                Min = AShape.Left
            End If
            i = AShape.Left + AShape.Width / 20
            If Max < i Then
                Max = i
            End If
            ShapeCol.Add AShape
            Total = Total + AShape.Width / 20
        Next AShape
        SortHorizontal ShapeCol
        Interval = (Max - Min - Total) / (ShapeCol.Count - 1)
        Total = ShapeCol(1).Left
        For Each AShape In ShapeCol
            AShape.Left = Total
            Total = Total + AShape.Width / 20 + Interval
        Next AShape
    End If
End Sub

Sub DistributeVertical()
Dim Min, Max, i, Total, Interval As Single
Dim ShapeCol As Collection
    If Selection.ChildShapeRange.Count > 1 Then
        Min = 32768
        Max = -32768
        Total = 0
        Set ShapeCol = New Collection
        For Each AShape In Selection.ChildShapeRange
            If Min > AShape.Top Then
                Min = AShape.Top
            End If
            i = AShape.Top + AShape.Height / 20
            If Max < i Then
                Max = i
            End If
            ShapeCol.Add AShape
            Total = Total + AShape.Height / 20
        Next AShape
        SortVertical ShapeCol
        Interval = (Max - Min - Total) / (ShapeCol.Count - 1)
        Total = ShapeCol(1).Top
        For Each AShape In ShapeCol
            AShape.Top = Total
            Total = Total + AShape.Height / 20 + Interval
        Next AShape
    End If
End Sub

August 4, 2011

MS Word Drawing Canvas Hack #2

(#3 was added on Oct 7. 2011.)

As I mentioned yesterday, we can “kaizen” the behavior of MS Word.

But it’s too much of a bother to call a macro everytime.
So let’s register these macro to the ribbon.

First, open “Option”. Then…

  1. Select “Ribbon Settings”
  2. Select “Macro”
  3. Select “Tool Tab” from “Ribbon Settings” and select “Drawing Tool > Format > Align”

Word Option

  1. Make new group
  2. Add macro
  3. And rename them

Make them as button

Then you can find buttons on the ribbon.
Buttons

Then you may get “Development” ribbon invisible.

August 3, 2011

MS Word Drawing Canvas Hack

(#2 and #3 are available.)

Recently I’ve realized that there is a particular problem caused by the behavior of Microsoft Word 2010.
The behavior is that items on drawing canvas can not be aligned using align function.
c.f. Microsoft Answers

So I’ve written some tiny code to enable aligning them.

Here are some piece of screenshot to explain how to do.
However since I have only Japanese Environment so please imagine and guess what is told by them.
Sorry.

Drawing canvas & align function

Drawing canvas & align function


Lines in red font in a picture above means “Align functions are grayout and disabled for the items on drawing canvas”.

Then, the procedure below.
Please Poke your settings at your own risk. OK?

At first, to use macro and VBA, Make “Development” ribbon visible in the “Option” menu.
Word option

Then open “Visual Basic”.
Right click on “Normal” and insert “Module”.

Add 'Module'

Add 'Module'


This “Normal” is usually like a default settings included when a new document is created.
So once you add a macro code to it, you can use this function everytime you work with a new file.
And you don’t have to worry about things around security because this code will not be included in the document file itself.

Then copy the code below and paste to “Module1” in the module.

Private Sub AlignHorizontal(ARate As Single)
Dim Min, Max, i As Integer
    Min = 32768
    Max = -32768
    For Each AShape In Selection.ChildShapeRange
        If Min > AShape.Left Then
            Min = AShape.Left
        End If
        i = AShape.Left + AShape.Width / 20
        If Max < i Then
            Max = i
        End If
    Next AShape
    For Each AShape In Selection.ChildShapeRange
        AShape.Left = Min * (1 - ARate) + Max * ARate - AShape.Width / 20 * ARate
    Next AShape
End Sub

Private Sub AlignVertical(ARate As Single)
Dim Min, Max, i As Integer
    Min = 32768
    Max = -32768
    For Each AShape In Selection.ChildShapeRange
        If Min > AShape.Top Then
            Min = AShape.Top
        End If
        i = AShape.Top + AShape.Height / 20
        If Max < i Then
            Max = i
        End If
    Next AShape
    For Each AShape In Selection.ChildShapeRange
        AShape.Top = Min * (1 - ARate) + Max * ARate - AShape.Height / 20 * ARate
    Next AShape
End Sub

Private Sub AlignShape(AHorizontal As Boolean, ARate As Single)
    If Selection.ChildShapeRange.Count = 0 Then
        Exit Sub
    End If
    If AHorizontal Then
        AlignHorizontal (ARate)
    Else
        AlignVertical (ARate)
    End If
End Sub

Sub AlignHorizontalLeft()
    AlignShape True, 0
End Sub

Sub AlignHorizontalCenter()
    AlignShape True, 0.5
End Sub

Sub AlignHorizontalRight()
    AlignShape True, 1
End Sub

Sub AlignVerticalTop()
    AlignShape False, 0
End Sub

Sub AlignVerticalMiddle()
    AlignShape False, 0.5
End Sub

Sub AlignVerticalBottom()
    AlignShape False, 1
End Sub

Save the code, and that's all!

Select items on a drawing canvas, click "Macro" button on "Development" ribbon, select registered macro and execute.
Please guess which macro behaves how from the name of it.
It seems that it won't work with items OUTSIDE the drawing canvas.
Use the original align functions.

(2011.8.4: "Register macro to a button" Added.)

This code is free to use and you can change/rewrite it as you like.
But I'm happy if you provide some link to this page when you introduce this issue.

And I'm glad to know if there is some mistranslation of menu words or if there is some better way to solve this problem.
Let me know by comment below when you have something to tell me.
I'm not sure that I can reply all of the comments.
If such is the case, please disregard it.
Thank you.


Powered by WordPress, WP Theme designed by WSC Project.