오랜만에 글을 올리네요.
요즘은 비지오 카페 매니저로 활동하느라... 이곳까지 자료를 잘 남기지 못하고 있습니다.
마침.. 네이버에 파일이 안올라가서.. ㅋㅋ
이곳에 질문에 대한 답변 남깁니다.

질문은... 클릭하면 주석이 보이도록 하는.. 셰이프에 관한 것이었습니다. ^^

답변..


컴퓨터 셰이프도 약간의 수정이 필요해서 셰이프 시트 조금 이용했구요.

대부분은 VBA에서 작업했습니다.


다른 셰이프를 동일하게 동작시키고자 할 경우에는

첨부 문서의 컴퓨터 셰이프를 참고하시기 바랍니다.


또 간단히 설명드리면..

1. 컴퓨터 셰이프에 주석 셰이프를 추가한 뒤 그룹화시킵니다.

2. 그룹 셰이프의 셰이프 시트 창을 열고 User.show 셀을 생성합니다.

3. 그룹 셰이프의 이름을 확인합니다.

4. 주석 셰이프를 선택하여 셰이프 시트 창을 열고 Geometry1.noshow 부분에 "그룹 셰이프의 이름!user.show" 라고 입력하고 닫습니다.


이상 위와 같이 하면 다른 셰이프들도 같은 VBA 코드로 이용하실 수 있는데요.

혹시 잘 안되신다거나 그렇게 바꾸어야할 셰이프가 많다면..

위 과정도 코드로 처리할 수는 있습니다.


제가 짬이 많지는 않아서 그것까지 지금 만들어드리기는 어렵고요... ^^;;

나중에 짬날 때.. 또 만들어서 올려볼게요..


도움이 되시길..

http://bvisual.spaces.live.com/default.aspx  bVisual's blog

http://www.eggheadcafe.com/default.aspx  Q/A
7/7/2005 10:27:03 AM    SaveAsWebPage Code Fix
I have been coming to these groups for several years now trying to find  
  
a solution to the Save As Web Page problem of having mouse-overs and  
  
hyperlinks were together on the same shape and diagram.  So I finally  
  
got a chance recently to write some VBA code to fix that problem.  Here  
  
it is.  Hopefully it will help others.  
  
'Written by Steve Lin, Cognizant Design,  
  
'steve.lin@cognizantdesign.com  
  
Public Sub VisioUpdate()  
  
Call WriteScreenTips  
  
Call UpdateFramesetJS  
  
Call UpdateHTM  
  
End Sub  
  
Public Sub WriteScreenTips()  
  
Dim pags As Visio.Pages  
  
Dim pag As Visio.Page  
  
Dim shp As Visio.Shape  
  
Dim sText As String  
  
' Set up Constants  
  
Const ForWriting = 2 ' Input OutPut mode  
  
Const Create = True  
  
Dim MyFile  
  
Dim FSO ' FileSystemObject  
  
Dim TSO ' TextStreamObject  
  
'On Error Resume Next  
  
MyFile = Left(Visio.ActiveDocument.Name, Len(Visio.ActiveDocument.Name)  
  
- 4) & "_files\ScreenTips.xml"  
  
Set FSO = CreateObject("Scripting.FileSystemObject")  
  
Set TSO = FSO.OpenTextFile(MyFile, ForWriting, Create)  
  
Set pags = Visio.ActiveDocument.Pages  
  
TSO.Writeline "<?xml version=""1.0"" encoding=""utf-8""?>"  
  
TSO.Writeline "<VisioDocument>"  
  
TSO.Writeline "<Pages>"  
  
For Each pag In pags  
  
TSO.Writeline "<Page ID=""" & pag.ID & """ >"  
  
TSO.Writeline "<Shapes>"  
  
For Each shp In pag.Shapes  
  
sText = shp.Cells("Comment").ResultStr("")  
  
If sText > "" Then  
  
sText = "<Shape ID=" & Chr(34) & shp.ID & Chr(34) & "  
  
Name=" & Chr(34) & shp.Name & Chr(34) & "><Tip>" & sText &  
  
"</Tip></Shape>"  
  
TSO.Writeline sText  
  
End If  
  
Next shp  
  
TSO.Writeline "</Shapes>"  
  
Next pag  
  
TSO.Writeline "</Page>"  
  
TSO.Writeline "</Pages>"  
  
TSO.Writeline "</VisioDocument>"  
  
TSO.Close  
  
Set TSO = Nothing  
  
Set FSO = Nothing  
  
End Sub  
  
Public Sub UpdateFramesetJS()  
  
Dim sText As String  
  
' Set up Constants  
  
Const ForAppending = 8 ' Input OutPut mode  
  
Const Create = True  
  
Dim MyFile As String  
  
Dim FSO ' FileSystemObject  
  
Dim TSO ' TextStreamObject  
  
'On Error Resume Next  
  
MyFile = Left(Visio.ActiveDocument.Name, Len(Visio.ActiveDocument.Name)  
  
- 4) & "_files\frameset.js"  
  
Set FSO = CreateObject("Scripting.FileSystemObject")  
  
Set TSO = FSO.OpenTextFile(MyFile, ForAppending, Create)  
  
MyFile = Left(Visio.ActiveDocument.Name, Len(Visio.ActiveDocument.Name)  
  
- 4) & "_files/ScreenTips.xml"  
  
TSO.Writeline "var xmlDataScreenTips = XMLData(" & Chr(34) & MyFile &  
  
Chr(34) & ");"  
  
TSO.Writeline "function GetScreenTip (pageID, shapeID)"  
  
TSO.Writeline "{"  
  
TSO.Writeline "    var shapeObj = null;"  
  
TSO.Writeline ""  
  
TSO.Writeline "    if (xmlDataScreenTips)"  
  
TSO.Writeline "    {"  
  
TSO.Writeline "        var pagesObj =  
  
xmlDataScreenTips.selectSingleNode(""VisioDocument/Pages"");"  
  
TSO.Writeline "        if(!pagesObj)"  
  
TSO.Writeline "        {"  
  
TSO.Writeline "            return null;"  
  
TSO.Writeline "        }"  
  
TSO.Writeline "        "  
  
TSO.Writeline "        var pageQuerryString = './/Page[@ID = ""' +  
  
pageID + '""]';"  
  
TSO.Writeline "        var pageObj =  
  
pagesObj.selectSingleNode(pageQuerryString);"  
  
TSO.Writeline "        if(!pageObj)"  
  
TSO.Writeline "        {"  
  
TSO.Writeline "            return null;"  
  
TSO.Writeline "        }"  
  
TSO.Writeline ""  
  
TSO.Writeline "        var shapeQuerryString = './/Shape[@ID = ""' +  
  
shapeID + '""]';"  
  
TSO.Writeline "        shapeObj =  
  
pageObj.selectSingleNode(shapeQuerryString);"  
  
TSO.Writeline "    }"  
  
TSO.Writeline "    return shapeObj;"  
  
TSO.Writeline "}"  
  
TSO.Close  
  
Set TSO = Nothing  
  
Set FSO = Nothing  
  
End Sub  
  
Public Sub UpdateHTM()  
  
Dim sText As String  
  
' Set up Constants  
  
Const ForReading = 1 ' Input OutPut mode  
  
Const ForWriting = 2 ' Input OutPut mode  
  
Const Create = True  
  
Dim MyFileHtm As String  
  
Dim MyFileTxt As String  
  
Dim FSO ' FileSystemObject  
  
Dim TSO ' TextStreamObject  
  
Dim TSOO ' TextStreamObject  
  
'On Error Resume Next  
  
MyFileHtm = Left(Visio.ActiveDocument.Name,  
  
Len(Visio.ActiveDocument.Name) - 4) & ".htm"  
  
Set FSO = CreateObject("Scripting.FileSystemObject")  
  
Set TSO = FSO.OpenTextFile(MyFileHtm, ForReading)  
  
MyFileTxt = Left(MyFileHtm, Len(MyFileHtm) - 4) & ".txt"  
  
Set TSOO = FSO.OpenTextFile(MyFileTxt, ForWriting, Create)  
  
Do While sText <> "function UpdateTooltip (element, pageID, shapeID)"  
  
sText = TSO.Readline  
  
If sText <> "function UpdateTooltip (element, pageID, shapeID)"  
  
Then  
  
TSOO.Writeline sText  
  
End If  
  
Loop  
  
TSOO.Writeline "function UpdateTooltip (element, pageID, shapeID)"  
  
TSOO.Writeline "{"  
  
TSOO.Writeline "    if (isUpLevel)"  
  
TSOO.Writeline "    {"  
  
TSOO.Writeline "        var strHL, strProps;"  
  
TSOO.Writeline ""  
  
TSOO.Writeline "        if(frmDrawing.event.type == ""focus"")"  
  
TSOO.Writeline "        {"  
  
TSOO.Writeline "            strHL = strFocusHLTooltipText;"  
  
TSOO.Writeline "            strProps = strFocusPropsTooltipText;"  
  
TSOO.Writeline "        }"  
  
TSOO.Writeline "        else"  
  
TSOO.Writeline "        {"  
  
TSOO.Writeline "            strHL = strHLTooltipText;"  
  
TSOO.Writeline "            strProps = strPropsTooltipText;"  
  
TSOO.Writeline "        }"  
  
TSOO.Writeline ""  
  
TSOO.Writeline "        var strTooltip = """";"  
  
TSOO.Writeline "        if (element.origTitle)"  
  
TSOO.Writeline "        {"  
  
TSOO.Writeline "            strTooltip = element.origTitle.toString();"  
  
TSOO.Writeline "        }"  
  
TSOO.Writeline ""  
  
TSOO.Writeline "        var shapeNodeScreenTip = GetScreenTip (pageID,  
  
shapeID);"  
  
TSOO.Writeline "        if( shapeNodeScreenTip != null )"  
  
TSOO.Writeline "        {"  
  
TSOO.Writeline "        strTooltip = shapeNodeScreenTip.text;"  
  
TSOO.Writeline "        }"  
  
TSOO.Writeline "        "  
  
TSOO.Writeline "        var shapeNode = FindShapeXML (pageID,  
  
shapeID);"  
  
TSOO.Writeline "/*"  
  
TSOO.Writeline "        if( shapeNode != null )"  
  
TSOO.Writeline "        {"  
  
TSOO.Writeline "            var propColl = shapeNode.selectNodes  
  
(""Prop"");"  
  
TSOO.Writeline "            if (propColl != null && propColl.length >  
  
0)"  
  
TSOO.Writeline "            {"  
  
TSOO.Writeline "                if (strTooltip.length > 0)"  
  
TSOO.Writeline "                {"  
  
TSOO.Writeline "                    strTooltip += ""\n"";"  
  
TSOO.Writeline "                }"  
  
TSOO.Writeline "                strTooltip += propColl(0).text;  
  
//strProps; s/b for each prop get text"  
  
TSOO.Writeline "            }"  
  
TSOO.Writeline "        }"  
  
TSOO.Writeline "        "  
  
TSOO.Writeline "        var hlObj = GetHLAction (shapeNode, pageID,  
  
shapeID);"  
  
TSOO.Writeline "        if (hlObj != null && (hlObj.DoFunction.length >  
  
0 || hlObj.Hyperlink.length > 0))"  
  
TSOO.Writeline "        {"  
  
TSOO.Writeline "            if (strTooltip.length > 0)"  
  
TSOO.Writeline "            {"  
  
TSOO.Writeline "                strTooltip += ""\n"";"  
  
TSOO.Writeline "            }"  
  
TSOO.Writeline "            if HLObj.Desc != ""undefined"" {"  
  
TSOO.Writeline "                strTooltip += HLObj.Desc; // strHL;  
  
This fix from microsoft visio forum"  
  
TSOO.Writeline "            }"  
  
TSOO.Writeline "        }"  
  
TSOO.Writeline "*/"  
  
TSOO.Writeline "        element.title = strTooltip;"  
  
TSOO.Writeline "        if (element.alt != null)"  
  
TSOO.Writeline "        {"  
  
TSOO.Writeline "            element.alt = strTooltip;"  
  
TSOO.Writeline "        }"  
  
TSOO.Writeline "    }"  
  
TSOO.Writeline "}"  
  
TSOO.Writeline ""  
  
Do While sText <> "function GetHLAction (shapeNode, pageID, shapeID)"  
  
sText = TSO.Readline  
  
Loop  
  
TSOO.Writeline sText  
  
Do While Not TSO.AtEndOfStream()  
  
sText = TSO.Readline  
  
TSOO.Writeline sText  
  
Loop  
  
TSO.Close  
  
Set TSO = Nothing  
  
FSO.DeleteFile MyFileHtm  
  
FSO.CopyFile MyFileTxt, MyFileHtm, True  
  
'FSO.DeleteFile MyFileTxt  
  
Set FSO = Nothing  
  
End Sub

Visio 2007 Trick: 3-Point Gradient Fills with Transparency

A Question

How many shapes are required to draw the image below in Visio?

image

The Answer

5 shapes.

No groups, no wierd geometries. Just 5 shapes.

What I want

I want rich, smooth, multi-color gradient fills with independent transparencies for each color.

I could get what I want by drawing multiple shapes. That can work. But, sometimes it's irritating. The shapes have to be perfectly aligned, you'll have some selection wierdness, etc. Simpler to have 1 shape.

What is a  3-Point Gradient Fill with Transparency?

Before I show the steps. Let me give you a clearer understanding of what I mean.

First, here is a conceptual drawing the 3-point I really want to draw:

image

Now, without getting into the explanation, the gradient we'll be able to draw will be more like this:

image

So visualize it forming like this:

image

Implementing 3-Point Gradient Fill with Transparency

We are going to use a combination of the normal shape fills and the SHADOW feature to draw a 3-point gradient.

It's not perfect, it doesn't do everything you'd expect in an application like Illustrator, but I'm sure it's more than what you've seen with Visio so far.

Just so that the goal is clear: here is what we will end-up with:

image

  • ORANGE in the upper left
  • LIGHT BLUE in the upper-right
  • DARK BLUE in along the bottom

Steps

  • Launch Visio
  • Create a new document
  • Draw a rectangle

image

  • Select the rectangle, right-click, and choose Format / Fill...

image

  • The Fill dialog will appear

image

  • Set the colors appropriately (pay attention)
  • Set the Fill / Pattern to 36

image

  • Set Fill / Color and FIll / Pattern Color to the color you want for the upper left (ORANGE)

image

  • Don't touch the transparency for now
  • Set the Shadow / Pattern to 28

image

  • Set Shadow / Color to the color you want along the bottom of the shape (DARK BLUE)
  • Set Shadow / Pattern Color to the color you want at the upper right of the shape (LIGHT BLUE)
  • Click OK
  • Here is what you have now

image

  • Turn on the shape sheet via Tools / Options / Advanced / Run in developer mode and click OK to close the Tools / Options dialog

image

  • Select the shape, right click, and select Show ShapeSheet
  • Find the FIllBkgndTrans cell and change the value from 0% to 100%

image

  • You'll notice the change in the shape once you finish making this change

image

  • close the shapesheet window

image

  • A closer look

image

  • Select the shape
  • Form the menu, select Format / Shadow ...

image

  • The Shadow dialog launches

image

  • Under the Size & Position section, click the black dot in the middle of all the arrows

image

  • A close-up of the black dot to click

image

  • Once you click the dot, the Shadow dialog will look like this

image

  • NOTE: when you click on the black dot, the Shadow / Style changed to "13: Offset, custom" (this is expected)
  • Click OK to close the Shadow dialog
  • What we have created is a single shape with a three-point gradient.

image

  • If you edit the fill and shadow transparencies, you can vary the transparencies as needed

That was hard, how can I create another one?

  • Just duplicate the object and edit the colors in the Fill dialog to get what you want.

What about an existing shape? How can I copy the effect?

  • Use the format painter button

image

How do I create the picture are the beginning of the post?

image

  • Duplicate this shape 4 times for a total of five shapes.
  • Resize and stack three on top of each other and modify the colors via the FIll dialog.
  • Make the other two into vertical columns, set the colors and the transparencies
  • Play with the patterns and transparencies. You'll get some nice combinations!

Summary

  • A single shape that avoids selection weirdness and keep the file size manageable
  • An easy way to change the colors
  • Trivial to generate a different gradients, you only need to use the shapesheet the first time: Create this shape once, save it as a file, if you ever want another gradient just reload, duplicate, change colors via the UI as desired.

 

Code CAN be attached to Visio Shapes

David A Edson

Mechanics and History

For a long time Visio has had a ShapeSheet function called RUNADDON(). This function was originally designed to call and launch additional functionality written as a .VSL (C or C++ DLL extension to Visio), or written as a stand-alone executable, .EXE (VB application). As VBA was introduced in Visio Technical and Professional under 4.5 and extended to the entire product line under 5.0, the RUNADDON() function can now call VBA functionality as well. You would normally add an ACTIONS section to any Visio SmartShape symbol or to a page in a Visio document. The Action Cell would contain the RUNADDON() function with its only argument being the name of the .VSL or .EXE that you desired to be launched. Below are two examples of this:

=RUNADDON("Property Reporting Wizard.EXE")

=RUNADDON("Valve Builder")

Note that no path to the .VSL or .EXE is listed. Rather, the .VSL or .EXE must be in Visio’s search path as set from the Tools > Options Dialog, in the File Paths Tab, on the Add-ons: line. Note that the file paths are semi-colon deliminated.

Presuming that you had created a VBA add-on named "Border_Colour", you could call it with the following syntax:

=RUNADDON("Border_Colour")

and Visio will be sable to suss out that it is a VBA code item and launch it appropriately.

Now here’s the slick wee bit o’ business….. Visio’s RUNADDON() function can also recognise standard VBA functions as weel as an argument to the function. The next two examples illustrate this making use of the lowly MsgBox VBA function:

=RUNADDON("MsgBox ""I’ve been clicked!""")

=RUNADDON("For I = 1 to 5 ; MsgBox I ; Next I")

Lets have a wee look at the first… In this case the RUNADDON() function is calling VBA’s MsgBox function a single time and displaying the text "I’ve been clicked!" in the message box. Note that the string to be displayed must be enclosed in double-double-quotes in order for the function parser to understand that it is text, and the entire argument to the RUNADDON() function must be a quoted string. This explains the preponderance of double-quotes in the code.

The second case calls VBA’s MsgBox function five times, and displays the numbers "1", "2", "3", "4", and "5" in each successive message box. Note that each "line" of VBA cone is deliminated here with a colon, and as such three lines of VBA code are executed.

Be aware of the limitations of string length in a Visio SmartShape symbol’s ShapeSheet cell. It is generally about 127 characters. You can programmatically force greater length strings into a cell formula but ANY attempt to access or edit the cell at a later date will truncate it back to the 127 character limit, thereby rendering it, quite, possibly, unusable.

A few wee examples

In this first example, I am gang tae add a wee bit of functionality tae a Shape’s Double-Click event as found in the EventDoubleClick cell in the Events section of the ShapeSheet. This functionality will pop up a message box and display the shape’s Name and filled area each time the shape is double-clicked. The single line of code in the cell looks like:

=RUNADDON("Set shp = ActiveWindow.Selection(1) : s = ""Shape Name = "" & shp.Name : s = s & chr(13) : s = s & ""Shape Area = "" & shp.AreaIU & "" Square Inches."" : MsgBox s")

Breakin’ this doon… RUNADDON() is first bindin’ the variable "shp" to the currently selected shape, that is the first item in the selection collection of the active window. Then a variable "s" is set to the string "Shape Name = " and the concatinated name property of the shape "shp" object. This string is then concatinated with a character string "13", which is a carrage return, and further concatinated with the string "Shape Area = " and the concatinated area-in-internal-units property of the shape "shp" object. Finally this full concatinated string is passed as the argument "s" to the VBA MsgBox() function.

Presumin’ tha’ the shape is a rectangle 3 inches wide by 2 inches tall and it is the third shape on the current page, the output to the message box would be:

Shape Name = Sheet.3

Shape Area = 6 Square Inches.

If this same code were to be written in the VBA editor it would look like:

Public Sub WhoAmI ()
Dim shp As Visio.Shape
Dim s As String
Set shp = Visio.ActiveWindow.Selection.Item(1)
s = "Shape Name = " & shp.Name
s = s & chr(13)
s = s & "Shape Area = " & shp.AreaIU & " Square Inches."
MsgBox s
End Sub

If packin’ a’ tha’ code intae a single line is causin’ ye tae "fash" (worry, for those of you not of the Celtic persuasion), you can place the individuaql pieces into User Defined Cells and then concatenate them into the EventDoubleClick cell similar to the following:

User.L10 = "For i = 1 to 3 :"
User.L20 = "MsgBox i:"
User.L30 = "Next i"
EventDblClick = RUNADDON(User.L10 & User.L20 & User.L30)

In this second example, I’m going to show you how you can place a large notes field as an attachment to any shape. The user can read an’ edit the notes as required. To accomplish this you will need to add an Actions section to your ShapeSheet. This will allow the user to "right-click" on the shape and call your functionality. You will be setting the values of both the Menu cell and the Action cell in the Actions section.

Actions[1].Menu = "Notes…"

Actions[1].Action = RUNADDON("Set shp = ActiveWindow.Selection(1) : p = shp.Data1 : t = ""Notes for "" & shp.Name : d = shp.Data1 : ib = InputBox(p,t,d) : If ib <> """" Then shp.Data1 = ib")

The VBA equivalent looks similar to:

Public Sub MyNotes ()
Dim shp As Visio.Shape
Dim p As String
Dim t As String
Dim d As String
Dim ib As String
Set shp = Visio.ActiveWindow.Selection.Item(1)
p = shp.Data1
t = "Notes for " & shp.Name
d = shp.Data1
ib = InputBox(p, t, d)
If ib <> " " Then shp.Data1 = ib
End Sub

Note tha’ we need tae check the string returned by the input box tae see if it is empty.

If ib <> " " Then shp.Data1 = ib

If the Cancel button on the Input Box were clicked, then the string returned would be empty. Without this check, the statement:

shp.Data1 = ib

would clear oot the notes when the Cancel button was clicked. This micht no’ be what ye had desired, especially if there were lots of notes to the shape, oor the user thought that Cancel just meant that he oor she didn’t want to change anything. However, the functionality above negates the possibility of truly deleting the note if that is what the user actually had in mind. To remedy this the following Actions line will clear oot the notes content:

Actions[1].Menu = "Clear Notes"

Actions[1].Action = RUNADDON("ActiveWindow.Selection(1).Data1 = "" ")

Weel thar ye ha’e it folk!!! You can now set aboot addin’ yer ain notes to Visio SmartShapes symbols and additionally, begin tae experiment wi’ addin’ your own bits o’ VBA functionality to your verra smart Visio shapes!!!

I want tae thank Chris Roth at Visio for a’ his weark in researchin’ an’ documentin’ this functionality!!! Ceuid Mile Thanks Chris Laddie!!!!!

‘Till next month, enjoy yer American Thanksgivin’, dinnae eat tae much, tak a weel desearved rest, an…

"Haste ye back."

다음과 같은 라이브러리가 들어있는 화학 템플릿과 스텐실입니다.

다운로드

사용자 삽입 이미지


비지오 물리 템플릿 입니다.

아래와 같이 광학, 물리실험, 전자기학, 역학을 표현할 수 있는 템필릿과 스텐실들이 포함되어 있습니다.

사용자 삽입 이미지