How to change column values in shapesheet using VBA

Started by nilani, July 24, 2011, 02:36:18 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nilani

Hi,

Again another question :). In the shapesheet "Shape Data section" 6th column is "Value". I want to change this value using VBA. I provide an interface using VBA and when the user clicks a button the "Value" column has to be change relevantly. Help me please?

Regards,
Nila.

aledlund

have you bothered to examine the code samples in the visio sdk
hint : SetCustomPropertyValue
al

nilani

#2
Hi Al,

I have installed sdk. I searched in the developer reference,but SetCustomPropertyValue was not there? :( actually what I wanted is to change shapesheet values using VBA?

aledlund

#3
v2010 sdk => code samples => vba => custom properties => add custom property => set custom property


'  modSettingACustomProperty / SettingACustomProperty.bas
' Copyright (c) Microsoft Corporation.  All rights reserved.
'
' Summary:
' This module demonstrates how to programmatically set the values for custom
' custom property (shape data) types on a shape.

Public Sub SetCustomPropertyValue(vsoShape As Visio.shape, _
    strRowNameU As String, _
    varValue As Variant, _
    vsoUnit As Visio.VisUnitCodes)

' SetCustomPropertyValue
'
' Abstract - This procedure assigns a value to a custom
' property cell with the universal row name (strRowNameU)
' in the shape (vsoShape) using the value and units passed
' in as parameters.
'
' Parameters
' vsoShape          Specifies the shape which has the
'                   custom property
'
' strRowNameU       Specifies the univeral name of the
'                   custom property
'
' varValue          Specifies the value of the custom
'                   property
'
' vsoUnit           Specifies the units of the value of
'                   the custom property
   
    Const CUST_PROP_PREFIX  As String = "Prop."
    Dim vsoCell As Visio.Cell
   
    On Error GoTo SetCustomPropertyValue_Err
   
    ' Check to see if the shape has custom property
    ' value cell with this universal row name. If no
    ' cell exists display an error message and exit
    ' this procedure.
    If Not vsoShape.CellExistsU(CUST_PROP_PREFIX & _
            strRowNameU, False) Then
           
        If (vsoShape.Application.AlertResponse = 0) Then
            MsgBox "This shape does not have a custom" & vbCrLf & _
                   "property with the universal name:" & vbCrLf & _
                   "'" & strRowNameU & "'."
        End If
       
        Exit Sub
    End If
     
    ' Get the Cell object. Note the addition of "Prop."
    ' to the name given to the cell.
    Set vsoCell = vsoShape.CellsU(CUST_PROP_PREFIX _
        & strRowNameU)
    If (vsoUnit = visUnitsString) Then

        SetCellValueToString vsoCell, CStr(varValue)

    Else
        ' Use the Result method to set values other than
        ' String type.
        vsoCell.result(vsoUnit) = varValue
    End If
   
    Exit Sub
   
SetCustomPropertyValue_Err:
    Debug.Print Err.Description
                     
End Sub


nilani

Hi Al,

Thank you very much for the code. I want to tell you that I'm at very basic level in visio. I have attached a word document
illustrating what I supposed to do. Can you please provide me the  exact code for what I meant to do??. Then I can learn and do the rest.
Codes in the SDK are too complicated for me.

aledlund

That actually has to components that you appear to have problems with. a.) basic programming techniques and b.) interacting with Visio. I'd suggest an introductory book by David Edson 'professional development with visio 2000'. The book is still very relevant to beginning programmers.
al

nilani

Hi Al,

Thank you for your reply. I need to tell you that I know programming. I have experiences in VBA programming in MS Excel. The thing is I can not figure out how to change shapesheet values using VBA. Any way thank you very much for helping. :)