2

I'm trying to make a button in Access, that will open Visio and launch a Data Wizard to create a diagram. I've tried various solutions, but all I get is opening a blank Visio document (based on my template). The Wizard is not kicking in. For comparison, simply clicking on a template.vstx launches the wizard. I cannot reproduce this behavior from within VBA.

Many thanks for any tips

here is the code I'm working with:

 Function openvis()
 Dim vis As Visio.Application
 Set vis = CreateObject("Visio.Application")
 With vis
 .Visible = True
 .Documents.Add "C:\Templatev2.vstx"
 End With
 End Function     
CHAHI Saad
  • 309
  • 4
  • 15
Pawel127
  • 63
  • 7
  • Is this behaviour with exactly the same template with the same version of Visio? – Paul Herber Feb 18 '22 at 20:15
  • Possibly need to declare and set a Visio document object variable as I have seen done with Excel/Word/Outlook automation. – June7 Feb 18 '22 at 20:56
  • @PaulHerber: yes, both exactly the same – Pawel127 Feb 18 '22 at 23:24
  • @June7: any idea where can I find any information on that? I've reviewed many articles on the topic, but couldn't find any solution that would work. – Pawel127 Feb 18 '22 at 23:27
  • For Excel, after the .Add line: `.Dialogs(xlDialogFormulaFind).Show` to invoke the Find dialog window followed by `.UserControl = True`. So, maybe something like that for VIsio. I activated the **Microsoft Visio Viewer 14.0 Type Library** and searched its objects. Not finding a "Data Wizard". Not sure this is correct library but I don't have anything else. I do not have Visio to test with anyway. Did you try the FollowHyperlink suggestion yet? – June7 Feb 19 '22 at 09:06
  • I tried ````Application.FollowHyperlink "C:\Templatev2.vstx, , True```` Effect is the same, i.e. it opens the file, but Wizard does not kick in. – Pawel127 Feb 20 '22 at 00:03
  • @June7: unfortunately ````.Dialogs(xlDialogFormulaFind).Show```` does not compile in Access – Pawel127 Feb 20 '22 at 00:11
  • It works for me with Excel automation. I did not say it would be the same dialog for Visio. – June7 Feb 20 '22 at 00:49

2 Answers2

0

I created a VBA macro as follows:

 Sub test()
   Dim vis As Visio.Application
   Set vis = CreateObject("Visio.Application")
   With vis
     .Visible = True
     .Documents.Add "C:\Users\paul\Documents\Drawing1.vstx"
   End With
 End Sub

and it all works fine. Wizard starts.

Paul Herber
  • 1,150
  • 1
  • 7
  • 12
  • Hmm... For me this just opens the document and i need to push it manually by clicking on Data/Create for Wizard to start. May this be related to the version of Visio? Im using Microsoft® Visio® Plan 2 MSO (Version 2201 Build 16.0.14827.20186) 64-bit . What version did you use? – Pawel127 Feb 19 '22 at 23:57
  • Visio 2016 64-bit desktop. Maybe this is a limitation of the online version. – Paul Herber Feb 20 '22 at 08:21
  • No, I use desktop version as well. I'm stuck and have no idea what might cause my Wizard not launching. Id appreciate any suggestions. – Pawel127 Feb 20 '22 at 15:09
0

Finally i've found a solution that launches Visio data wizard on custom template from Access:

'CreateObject("Shell.Application").Open "C:\path\mytemplate.vstx"

Pawel127
  • 63
  • 7