News:

BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

Inserting Formulas in ShapeSheetCells via VBA

Started by big-igor, July 02, 2010, 12:18:06 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

big-igor

Hey guys,
I'm kind of desperate by now, I have a VBA form with 2 buttons on it. When clicking on one of them, i want Visio to insert a specific formula (that contains a reference to the selected shape group) into some cells of shape#123's ShapeSheet.
Problem: I click on Button1 --> The formula is inserted.
I click on Button2 --> The new formula should replace the old one, but nothing happens.

Could somebody help me out? Thanks in advance!!


Private Sub CommandButton1_Click()
        Dim xshape As Visio.Shape
        Dim groupid As Integer
        groupid = Application.ActiveWindow.Selection.PrimaryItem.id
        Set xshape = Application.ActiveWindow.Page.Shapes.ItemFromID(123)
        xshape.Cells("Geometry1.NoShow").Formula = "Sheet." & groupid & "!User.extHide"
        xshape.Cells("HideText").Formula = "Sheet." & groupid & "!User.extHide"
        xshape.Cells("Transparency").Formula = "Sheet." & groupid & "!User.extHide"
End Sub

Private Sub CommandButton2_Click()
        Dim xshape As Visio.Shape
        Dim groupid As Integer
        groupid = Application.ActiveWindow.Selection.PrimaryItem.id
        Set xshape = Application.ActiveWindow.Page.Shapes.ItemFromID(123)
        xshape.Cells("Geometry1.NoShow").Formula = "Sheet." & groupid & "!User.fsHide"
        xshape.Cells("HideText").Formula = "Sheet." & groupid & "!User.fsHide"
        xshape.Cells("Transparency").Formula = "Sheet." & groupid & "!User.fsHide"

End Sub

aledlund

I'd start with the fact that both buttons rely upon something being selected in the window, but you never test to see if a selection has really happened. I'd then wrap the code in a "on error goto " routine so that you can catch any errors that may be happening (right now your code can fail silently and you may get lost). Without a drawing with your custom shapes it's pretty much up in the air.
al

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 160 (show)
Files included: 35 - 1407KB. (show)
Memory used: 1069KB.
Tokens: post-login.
Cache hits: 14: 0.00288s for 26,723 bytes (show)
Cache misses: 4: (show)
Queries used: 17.

[Show Queries]