페이지

레이블이 VS 2008인 게시물을 표시합니다. 모든 게시물 표시
레이블이 VS 2008인 게시물을 표시합니다. 모든 게시물 표시

2011년 2월 22일 화요일

Visio 2007 Programming: Add master and change its name when new shape is added to a page

This code replace master name with its shape name.
Originally master is named like master.. The following code changes the name, master. to shape name such as Square, Pentagon, and etc.

Private Sub Application_ShapeAdded(ByVal Shape As Microsoft.Office.Interop.Visio.Shape) Handles Application.ShapeAdded

Dim strShapeName As String = ""
Dim nCount As Integer

Dim nMasterCnt As Integer
Dim tempMaster As Visio.Master
Dim tempMasterName As String

' Check whether a same type of shape is already added
' If a same type of shape exists, the name of newly added shape will
' ShapeName.Number. The period mark will be used to determine
' the duplication of shapes and the number represents
' the total number of shapes in the document
strShapeName = Shape.NameU

' Place newly added shape to the stencil as a master
vsoStencil.Drop(Shape, 1, 1)

' Set name for newly added master
' Get the number of masters in the stencil
nMasterCnt = vsoStencil.Masters.Count
For i = 1 To nMasterCnt
tempMaster = vsoStencil.Masters.Item(i)
tempMasterName = tempMaster.Shapes.ItemU(1).NameU
If tempMasterName = Shape.NameU Then
vsoStencil.Masters.ItemU(i).Name = Shape.NameU
End If
Next
End Sub

2011년 2월 20일 일요일

Visio 2007 Programming: Change stencil title

Imports Microsoft.Office.Interop.Visio
Public Class ThisAddIn
Private vsoDoc As Visio.Document
Private Sub ThisAddIn_Startup(ByVal sender As Object, _
ByVal e As System.EventArgs ) _
Handles Me.Startup
vsoDoc = Application.Documents.Add("")
vsoDoc = Application.Documents.OpenEx("Basic Shapes.vss", _
VisOpenSaveArgs.visOpenDocked + VisOpenSaveArgs.visOpenCopy)
End Sub

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

End Sub
End Class

Above code creates a blank document with docked basic shape stencil. However, the title of stencil window is "Stencil 2" and the number is constantly changing whenever a new document is created. So, How do I set the title with a meaningful name?

To solve this problem, add following statement after a document is created or opened.

vsoDoc.Title = "Basic Shapes"

2011년 2월 17일 목요일

Visual Studio 2008 FaceId

Visual Basic으로 Office Tool Add-In을 개발하는 중.

1단계로 Command Button에 생성하고 지우기.

Command Button 생성 코드는 http://msdn.microsoft.com/library/bb981205.aspx를 따라하면되고, 생성된 Button을 Disable또는 Delete하는 코드는 좀 고민해야겠다.

그런데, 위 URL의 코드를 자세히보면 FaceId 항목이 Integer로 지정되어 있다. 뭔가 싶어 찾아보니, 고맙게도 Microsoft에서 Office에서 사용하는 Icon들을 Resource로 배포하면서 번호를 부여한 것이다.예를 들어 다음 그림과 같이.



현재 4,000까지 Icon이 등록된 것 같다. 보다 자세한 Icon 정보는
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=12b99325-93e8-4ed4-8385-74d0f7661318&displaylang=en

http://www.kebabshopblues.co.uk/2007/01/04/visual-studio-2005-tools-for-office-commandbarbutton-faceid-property/를 참조하시를...