Monday, June 30, 2008

Getting the object of Running office Application

If you want to use the running excel object. You can use the following function:

private void getExcelApp()
{
try
{
objXlApp = (excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
}
catch
{
objXlApp = new excel.Application();
}
}

Friday, June 20, 2008

Setting RGB Colors for Excel 2007 Chart Series

Sub ColorChartSeriesWithRGB()
Dim chrt As Chart
Dim iSeries As Series
Dim colors(4, 3) As Integer
Dim i As Integer
Set chrt = ActiveChart
colors(1, 1) = 100
colors(1, 2) = 200
colors(1, 3) = 250
colors(2, 1) = 200
colors(2, 2) = 256
colors(2, 3) = 50
colors(3, 1) = 60
colors(3, 2) = 180
colors(3, 3) = 126
colors(4, 1) = 111
colors(4, 2) = 123
colors(4, 3) = 205
i = 1
For Each iSeries In chrt.SeriesCollection
iSeries.Format.Fill.ForeColor.RGB = RGB(colors(i, 1), colors(i, 2), colors(i, 3))
i = i + 1
Next iSeries
End Sub

Friday, June 13, 2008

Gallery Items in Ribbon

You can include the following code to implement the Gallery in your Ribbon.

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" loadImage="LoadImage" >
<ribbon startFromScratch="false">
<tabs>
<tab id="tab1" label="Gallery Demo" keytip="x" >
<group id="group1" label="Demo Group">
<gallery id="gallery1"
columns="2"
rows="2"
getEnabled="GetEnabled"
getScreentip="GetScreenTip"
supertip="This is the super tip."
getKeytip="GetKeyTip"
getShowImage="GetShowImage"
getShowLabel="GetShowLabel"
getLabel="GetLabel"
getSize="GetSize"
image="internetconnection.bmp"
getItemCount="GetItemCount"
getItemHeight="GetItemHeight"
getItemWidth="GetItemWidth"
getItemImage="GetItemImage"
getItemLabel="GetItemLabel"
getItemScreentip="GetItemScreenTip"
getItemSupertip="GetItemSuperTip"
onAction="galleryOnAction" >
<item id="item1" />
<item id="item2" />
<item id="item3" />
<item id="item4" />
<button id="button1" getLabel="GetLabel"
onAction="buttonOnAction"
imageMso="HappyFace" />
</gallery>
</group>
</tab>
</tabs>
</ribbon>
</customUI>


URL:

http://msdn.microsoft.com/en-us/library/bb736142.aspx

Wednesday, June 11, 2008

Reading Tags in Powerpoint

Sub ShowTags()
' Show me the tag name and value for each tag on each shape
' that has a tag on the currently displayed slide

Dim x As Long
Dim oSh As Shape

For Each oSh In ActiveWindow.View.Slide.Shapes
If oSh.Tags.Count > 0 Then
With oSh.Tags
For x = 1 To .Count
MsgBox oShName & vbtab & .Name(x) & vbTab & .Value(x)


Next ' x
End With
End If
Next ' oSh

End Sub

Sub AddTag()
' Adds the tag "TAGNAME" with value "TAGVALUE"
' to the currently selected shape

With ActiveWindow.Selection.ShapeRange(1)
.Tags.Add "TagName", "TagValue"
End With

End Sub

Sub ShowTagValue()
' Displays the current value of tag "TagName" on the selected shape

With ActiveWindow.Selection.ShapeRange(1)
MsgBox .Tags("TagName")
End With
End Sub


Source:

Tuesday, June 3, 2008

Optional Parameters in C#.net

Hi,

Optional parameters are not supported in C#, so we have to pass a value to every parameter while calling a method. But incase, if we don't want to pass any value to the parameter, we can use the global variable defined as Type.Missing.

Check the following link of MSDN Site:
http://msdn.microsoft.com/hi-in/library/ms178843(en-us).aspx#ValueTypes

Thanks,
Vikas

How Add-ins Work with the 2007 Microsoft Office System

A very good explanation of Add-in architecture in the following library:

http://msdn.microsoft.com/hi-in/library/bb386298(en-us).aspx

Thanks,
Vikas

Sunday, June 1, 2008

IDTExtensilibity2 Procedure to Add Menus

Hi all,

I would describe the procedures/steps that is followed when you try to add menu through IDTExtensilibity2 Interface.

Whenever office application is opened, it checks whether it can find any DLL registered for the application or not. If it finds any DLL registered, that DLL is loaded in the memory. The DLL is a kind of ADD-In, which is loaded automatically. This process of loading the DLL File, triggers five types of events.
  • On connection
  • OnStartupComplete
  • OnDisconnection
  • OnBeginShutdown
  • OnAddInsUpdate


  • To capture these events, your DLL File must implement IDTExtensibility2 Interface. This interface contains the definition of all these events. One can write the code for adding menus in onstartupcomplete method. It will force the application to add Menus after it loads the Add In.

    Hope I was able to clear the process.

    Thanks,
    Vikas