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();
}
}
Monday, June 30, 2008
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
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.
URL:
http://msdn.microsoft.com/en-us/library/bb736142.aspx
<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:
' 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:
Subscribe to:
Posts (Atom)