Thursday, August 19, 2010

EXCEL VBA for Copy, Position and Resize Picture

For catalogue program in excel, usually need process pictures.

Following excel VBA procedure is a useful example to do the job as copy picture from other sheet, position and resize it.

Public Sub s()

Dim oPic As Picture

Sheets("Sheet2").Select

'delete picture is it existed in target sheet

On Error GoTo errorhandling

Sheet2.Pictures("Phont_123").Delete

On Error GoTo 0 ' resume

errorhandling:

For Each oPic In Sheet1.Pictures
If (oPic.Name = "photo_1234567890") Then
Sheet1.Shapes(oPic.Name).Copy
Sheet2.Range("C3").PasteSpecial
Selection.Name = "Phont_123"
Dim p As Picture
Set p = Sheet2.Pictures("Phont_123")
' position picture base on cell C3's position
With Range("c3")
t = .Height
l = .Left
End With
' resize picture, this example fixed the height as 200,
With p
oh = .Height
ow = .Width
.Top = t
.Left = l
.Width = ow * 200 / oh
.Height = 200
.Placement = xlMoveAndSize
.PrintObject = True
End With
End If
Next oPic
End Sub

Monday, March 22, 2010

MOVEX workplace using IE8

  1. Set IE8 to Compatibility View for Movex workplace site by click 'Tools', then click 'Compatibility View Settings', then add website.
  2. Create shortcut for workplace login, the program is "C:\Program Files\Internet Explorer\iexplore.exe" –nomerge. the '–nomerge' parameter solve the IE8 session merge problem, please see following url for details.

    http://blogs.msdn.com/ie/archive/2009/05/06/session-cookies-sessionstorage-and-ie8.aspx

Tuesday, March 02, 2010

List file changes date

We can use following command to list the subdirectory and files with last changing date.

dir /s /od /tw Directory >list.txt