Visual Basic 6.0 & Visio 2007

Started by da_real, September 14, 2011, 04:12:01 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

da_real

hi to all, i integrated visio 2007 with vb6.0, and i just want to ask if how could i determine the location(x,y),height,and width of the shape that i added to my drawing control... thaks..

aledlund

Since you appear to be a beginner in this, you should start over here
http://msdn.microsoft.com/en-us/library/aa245244(v=office.10).aspx
and use the v2007 SDK (available on MS Download, not the v2010 sdk since it uses vba rather than vb6)
al

da_real

i already looked at the link that you gave me, but the thing is that this is a school project and i need to use a visual basic, is there any solution for my problem? i already inserted a drawing control from visio and i can now put some shapes, but my only problem is i cannot find the position,height,width of the shape i inserted..... t.y

aledlund

The first step is to capture a shape dropped event (to find the shape) and then check the pinx, piny, height, and width cells. The v2007 sdk has sample code using vb6 (I just checked)
http://www.microsoft.com/download/en/details.aspx?id=22006

here's some discussion on the drawing control
http://msdn.microsoft.com/en-us/library/aa173510(v=office.11).aspx

al

da_real

thanks for the advice.. i have another question... since i'm connecting shapes, how can i identify if this shape is connected with this shape using vb6.0.... thanks...

aledlund

I'd start in the v2007 sdk, vb6 section, connections and investigate showpageconnections.
al

da_real

hi al, since my system is using visio 2 create diagrams, can i compare 2 visio file if they are the same. a scenario could be logically they are the same but the 2 diagrams have their shapes in different positions..? thanks

aledlund

the usual suggestion is to save both the files as xml (.vdx) and then do a text compare against the two files. Besides that you would have to write custom code.
al

da_real

hi al, i tried this code to compare 2 files....
but it still wont work.. help me pls.. t.y

Public Function AreTheyTheSame(ByVal File1 As String, _
  ByVal File2 As String, Optional StringentCheck As _
  Boolean = False) As Boolean
'**********************************************************
'PURPOSE: Check to see if two files are identical
'File1 and File2 = FullPaths of files to compare
'StringentCheck (optional): If false (default),
'will only compare file lengths.  If true, a
'byte by byte comparison is conducted if file lengths are
'equal
'**********************************************************

On Error GoTo ErrorHandler

If Dir(File1) = "" Then Exit Function
If Dir(File2) = "" Then Exit Function

Dim lLen1 As Long, lLen2 As Long
Dim iFileNum1 As Integer
Dim iFileNum2 As Integer
Dim bytArr1() As Byte, bytArr2() As Byte
Dim lCtr As Long, lStart As Long
Dim bAns As Boolean

lLen1 = FileLen(File1)
lLen2 = FileLen(File2)
If lLen1 <> lLen2 Then
    Exit Function
ElseIf StringentCheck = False Then
        AreTheyTheSame = True
        Exit Function
Else
    iFileNum1 = FreeFile
    Open File1 For Binary Access Read As #iFileNum1
    iFileNum2 = FreeFile
    Open File2 For Binary Access Read As #iFileNum2

    'put contents of both into byte Array
    bytArr1() = InputB(LOF(iFileNum1), #iFileNum1)
    bytArr2() = InputB(LOF(iFileNum2), #iFileNum2)
    lLen1 = UBound(bytArr1)
    lStart = LBound(bytArr1)
   
    bAns = True
    For lCtr = lStart To lLen1
        If bytArr1(lCtr) <> bytArr2(lCtr) Then
            bAns = False
            Exit For
        End If
           
    Next
    AreTheyTheSame = bAns
       
End If

ErrorHandler:
If iFileNum1 > 0 Then Close #iFileNum1
If iFileNum2 > 0 Then Close #iFileNum2
End Function