Showing posts with label VSTO. Show all posts
Showing posts with label VSTO. Show all posts

24 June 2008

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{

Office.CommandBarComboBox webControl1 = (Office.CommandBarComboBox)this.Application.ActiveExplorer().CommandBars.FindControl(26, 1740, missing, missing);

webControl1.Text = "www.sa-action.blogspot.com";

}

07 September 2007

Lets create Outlook 2007 Add-In using Visual Studio 2005.

If you have not installed VSTO then Download Microsoft Visual Studio 2005 Tools for Office Second Edition Runtime (VSTO 2005 SE) (x86).


Start IDE.

Click on File, New project

Select Outlook Add-In and Click on OK.

you will find some code like this:

Public
Class ThisAddIn
 Private WithEvents btn1 As Office.CommandBarButton

Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup

End Sub


Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown

End Sub

End Class


Now add following code in StartUp event:

Dim explorer As Outlook.Explorer = Me.Application.ActiveExplorer()  

If explorer IsNot Nothing Then

Dim bar As Office.CommandBar = explorer.CommandBars.Add("saAction Bar", Temporary:=True)

bar.Visible = True

btn1 = bar.Controls.Add(Office.MsoControlType.msoControlButton, Temporary:=True)

btn1.Caption = "saAction Button"

btn1.Tag = "myOutlookAddin1.btn1"

btn1.Style = Office.MsoButtonStyle.msoButtonCaption

End If

And declare Button click event any where in the class.

 Private Sub Btn1_Click(ByVal ctrl As Office.CommandBarButton, ByRef cancelDefault As Boolean) Handles btn1.Click

MsgBox("Hi! this is VSTO")

End Sub


Done.

Now, Just run the project. Press F5, Outlook will automatically start and It will show a button there, and click on that button. See below "saAction Button" and messagebox.



Outlook is a very big application and using VSTO, you can utilize it's functions.

06 July 2007

With Visual Studio 2005 and Microsoft Office 2007 or 2003, I have created my own formula.



Open Visual Studio -> New -> Project.
Select "Class Library"

Your project name will show in Excel's Formula dialogbox.

Now you have a "Class1.vb" in your Solution Explorer.

Now right down this code in your Class file....

'imports required name space
Imports System.Runtime.InteropServices
Imports Microsoft.Win32


<ClassInterface(ClassInterfaceType.AutoDual), ComVisible(True)< _
Public Class Class1

'this is for automatically register the function in excel.
<ComUnregisterFunctionAttribute()> _
Public Shared Sub RegisterFunction(ByVal type As Type)
Registry.ClassesRoot.CreateSubKey(GetSubKeyName(type))
End Sub

'this is for to unregister the function from excel.
<ComUnregisterFunctionAttribute()> _
Public Shared Sub UnregisterFunction(ByVal type As Type)
Registry.ClassesRoot.DeleteSubKey(GetSubKeyName(type), False)
End Sub

Private Shared Function GetSubKeyName(ByVal type As Type) As String
Dim s1 As String
s1 = "CLSID\{" & type.GUID.ToString().ToUpper() & "}\Programmable"
Return s1.ToString()
End Function


'this is Excel custom formula "
myTestFormula"
Public Function myTestFormula(ByVal anyNumber As Double) As Double
Dim result As Double = anyNumber * 2
Return result
End Function

End Class

------------------
ok, open project properties form Project menu.

click on "Compile" Tab. and check a "Register for COM imterop" option.

now save all file of the project. and build solution pressing F6.

Ok, user defined function has been created. now we have to give reference to Excel for this formula.

  • Open Microsoft Excel 2007
  • open "Excel Options" from office button icon.
  • click on "Add-Ins" tab.
  • Click on "Go" button under Manage Excel Add-ins list.
  • It will show Add-Ins dialog box.

  • Click on Automation button.
  • Under Automation Services dialogbox fine out ProjectName.ClassName.
  • here I have "myExcelFormula.myFunctions" or like that.

click on OK.
it done.

now type your formula and pass it argument and you will get the result.

here you will get the result 10 (5*2)

it's g. using this method I am creating a Bill for a form. This is a print preview of a Bill using user defined function where database is MS Access, Software is Created in VB6.0 and this formula created from Visual Studio 2005.


19 June 2007

Check Micorosft Access 2007 Specifications before you decided to create your your database in Access.



  • Access database (.accdb) file size : 2 gigabytes,

  • Number of objects in a database : 32768

  • Number of modules : 1000

  • Number of characters in an object name : 64

  • Number of characters in a password : 20

  • user name or group name : 20 characters

  • Number of concurrent users : 255

  • No. of characters in a table name : 64

  • No. of characters in validation message : 255

  • Table or field description : 255 characters

  • Field property setting : 255 characters

  • Number of joins in a query : 16(depands)

  • Number of AND operators in a WHERE or HAVING clause 99(depands)

  • Number of characters in an SQL statement Approximately 64000(depands)

  • Number of characters in a label 2048 in report or form

  • Number of characters in a text box 65535 in report or form

  • Form or report width 22 in. (55.87 cm) only.

  • Number of levels of nested forms or reports : 7

  • Number of printed pages in a report : 65536

  • Number of actions in a macro : 999

Thousands of developer have many ma

These are some New Microsoft Excel 2007 Specifications and limitations. You have to check it before you select Microsoft Excel as your firm database.


  • Open workbooks : depands on system resource

  • Worksheet size : Rows: 1048576 and Columns: 16384 (XFD)

  • Maximum Sheets in a workbook : depands on system resource

  • Column width : 255 characters

  • Row height : 409 points

  • Page breaks : 1026 both horizontal and vertical

  • Total number of characters in a cell : 32767

  • Characters in a header or footer : 255

  • Unique cell formats/cell styles : 64000

  • Zoom range : 10% to 400%

  • Undo levels : 100

  • Parameters per Workbook : 255

  • Maximum arguments in a function : 255

  • Custom functions : depands on available memory

  • Worksheets referred to by a chart : 255

I think that small firm database can be easily handle by this Application. And when your are using Microsoft Excel 2007 there are many new feature, to create summary report.