Wednesday, December 12, 2007

export a matlab figure or simulink modell to powerpoint

Hi people

today i have something nice! i needed to export a simulink modell to powerpoint, and i did not want to make a screen shot. the clue is saveppt.

to use the program, i typed:

saveppt('test.ppt','title of the slide','-sTheNameOfTheModell')

Wednesday, December 5, 2007

check if a excel workbook is open

hi people, today, i discovered this function. it is very usefull, thanks to the authors.

the link to the function is here.
and the function is here:


Function WorkbookOpen(WorkBookName As String) As Boolean
' returns TRUE if the workbook is open
WorkbookOpen = False
On Error GoTo WorkBookNotOpen
If Len(Application.WorkBooks(WorkBookName).Name) > 0 Then
WorkbookOpen = True
Exit Function
End If
WorkBookNotOpen:
End Function

to call this function, use for example:

If Not WorkbookOpen("MyWorkbookName.xls") Then
Workbooks.Open "MyWorkbookName.xls"
End If

Monday, December 3, 2007

vba function to calculate the column value from a number

Hi, this function returns a script, which contains the value of the columns for excel. for example, if you call MyColumn(1), you'll get the string "A". If you call MyColumn(27), you'll get "AA".



Function myColumn(column As Integer) As String
'******************************
' author: tomas mezger
' tmezger_at_ffe.de
' date: 12.10.2007
'******************************
' this function returns a script, which contains the value of
' the columns for excel
' for example,
' MyColumn(1) = A
' MyColumn(26) = Z
' MyColumn(27) = AA
' MyColumn(100) = CV
' MyColumn(256) = IV
' MyColumn(257) = NULL <--- Error. Excel has only 256 columns!!!!

Dim column1 As Integer
Dim column2 As Integer


column2 = (column - 1) Mod 26 + 65
'MyColumn2 = Chr(column2)
' das liefert das hintere Teil des Bezuges
If column > 256 Then
myColumn = "NULL"
MsgBox ("Error, column must be <= 256 !!!")
Else
If column <= 26 Then
myColumn = Chr(column2)
Else
column1 = WorksheetFunction.RoundDown(((column - 1) / 26), 0) + 64
myColumn = Chr(column1) & Chr(column2)
End If
End If

End Function