Visio Guy

Visio Discussions => Programming & Code => Topic started by: elistein on May 12, 2015, 09:28:23 AM

Title: Visio Peculiar Behaviour
Post by: elistein on May 12, 2015, 09:28:23 AM
Hi

I have a problem tht drives me crazy for several days:

With Visio 2003 I have a Drawing with more then 400 Buttons and TextBoxes.

Everythind works fine until I added "RunModeEntered", which also works fine. U N T I L ....

Tested on 2 other computers, which are identical with the first one, but there

RunModeEntered doesn't fire. If i start a new Drawing with only this code' it works.

In my despair I uninstalled  ALL Microsoft Office, cleaned drive C and cleaned Registry

on all 3 computers and Reinstalled only Visio 2003.

Unbelievable, exactly the same: First computer fires the other two don't.

Any Ideas???
Title: Re: Visio Peculiar Behaviour
Post by: Yacine on May 12, 2015, 05:25:43 PM
Hi, what is RunModeEntered?
Title: Re: Visio Peculiar Behaviour
Post by: elistein on May 12, 2015, 05:41:22 PM
Hi

Finally found the reason, but dont know how to solve it properlly.

In the first computer I previously installed   Visual Basic 6, and when i needed

Common Dialog Control version 6 it just was there, but not on the other 2 computers.

My problem is how to add this control without installing Visual Basic.

Many thanks
Title: Re: Visio Peculiar Behaviour
Post by: elistein on May 12, 2015, 06:04:00 PM
Hi Yacine

RunModeEntered Mkes program to start with this Sub

But as you can see this is not the problem

Title: Re: Visio Peculiar Behaviour
Post by: Yacine on May 12, 2015, 09:01:26 PM
What do you need the common dialog for?
Title: Re: Visio Peculiar Behaviour
Post by: elistein on May 13, 2015, 05:42:16 AM
Hi Yacine

Thanks for your reply.

I need a code for Visio to implement like a "BROWSE"

There are many examples, but can't find one that

works for Visio 2003
Title: Re: Visio Peculiar Behaviour
Post by: Yacine on May 13, 2015, 06:21:04 AM
Hi Elistein,
to make it short: I suspect you are looking for a file dialogue.
There isn't one in Visio! One way to help yourself is to use Excel's integrated functionality.


Public Function OpenFile()
On Error GoTo ErrHandler
    Dim filenames As String
    Dim vFile As Variant
    Dim xlsApp As Excel.Application

    ' Use Excel's File Dialog
    Set xlsApp = New Excel.Application
    xlsApp.Visible = True
    vFile = xlsApp.GetOpenFileName("Visio File (*.vsd),*.vsd", 1, "Open File", "Open", False)
    xlsApp.Visible = False

    ' Open the file in Visio:
    If TypeName(vFile) = "String" Then
        Dim theDoc As Visio.Document
        Dim shp As Visio.Shape
        Dim sel As Visio.Selection
        Dim thePage As Page
        Set thePage = ActivePage
   
        ' Datei öffnen, Inhalt gruppieren und in shp zwischenspeichern
        Set theDoc = Application.Documents.OpenEx(vFile, visOpenHidden + visOpenRO)
        'The file is now opened, the ActiveDocument shows it.
        'Do something or leave

        ' You can close it if wanted
        Application.AlertResponse = 7
        theDoc.Close
        Application.AlertResponse = 0
        MsgBox "Operation finished"
    End If
Exit_Func:
    Set theDoc = Nothing
    Application.AlertResponse = 0
    Exit Function
ErrHandler:
    Debug.Print "Error in FileOpen "; Err.Description
    Resume Exit_Func


End Function
Title: Re: Visio Peculiar Behaviour
Post by: AndyW on May 13, 2015, 07:34:15 AM
Have you tried installing the VB6 run-time files,

https://www.microsoft.com/en-us/download/details.aspx?id=24417
Title: Re: Visio Peculiar Behaviour
Post by: elistein on May 14, 2015, 02:57:01 PM
Yacine, thanks for your suggestion.

After minor modifications:
Dim xlsApp As Excel.Application      >>>  .Visio                     
and
Set xlsApp = New Excel.Application  >> Visio

it's working.  But Your code actually starts a new file,

I need to "browse" to a certain folder, to see the files and to choose one.

Finally found an example that does exactly that:

http://visguy.com/vgforum/index.php?topic=738.0

And that solves my problem.

Still remained with the other Post about disable the X in the right corner (Did it successfully in VB6)

Thanks for everything
elistein
Title: Re: Visio Peculiar Behaviour
Post by: elistein on May 14, 2015, 03:01:17 PM
Hi AndyW

Thank you for your advice but then the code will work only on
computers that have VB6
Title: Re: Visio Peculiar Behaviour
Post by: Yacine on May 14, 2015, 04:27:28 PM
Hi Elistein,
you need to keep the code as I posted it. You way however need to reference the excel library.
Keep "Excel", browse for the file name, once you get it you continue with plain Visio.
Title: Re: Visio Peculiar Behaviour
Post by: AndyW on May 18, 2015, 08:38:27 AM
If your code is using a VB6 runtime dll/ocx then you should be distributing that with your application.
Title: Re: Visio Peculiar Behaviour
Post by: elistein on May 20, 2015, 04:14:37 PM
Hi
Thanks everybody for your much appreiciated help .