PDA

View Full Version : Visio not closing from Access VB command.



Raddrummer
03-26-2009, 12:29 PM
Hi there,

I have 2 issues happening that I could really use some help with. These are probably really easy....

1) I'm using VB in Access to generate a Visio org chart and then save it to my machine. I'm running into syntax issues near the bottom of the page for the Target of the new org chart. I've tried:
objAddOn2.Run "/QUIET=True /NAVBAR=False /SEARCH=true /TARGET="C:\Documents and Settings\SLozano\My Documents\OrgChart.htm"" but get an error.

2) The Quit command isn't working. I get a popup box asking if "I'd like to save changes to Document 1?" Any ideas on this one??


Here is the code I'm using. ANY help is appreciated.


Sub Generate()
Dim VisApp As Object
Dim visDoc As Visio.Document
Dim visExcelFile As String
Dim objAddOn As Object
Dim objAddOn2 As Object
Dim orgWizArgs As String
'Assign file location of Excel file that feeds into Visio
visExcelFile = "C:\Documents and Settings\SLozano\Desktop\VisioOCTest.xls"
'START VISIO'S ORG CHART WIZARD
Set VisApp = CreateObject("Visio.Application")
Set objAddOn = VisApp.Addons.ItemU("OrgCWiz")
objAddOn.Run ("/S-INIT")

'Add org chart arguments
orgWizArgs = " /FILENAME=" & visExcelFile & " /NAME-FIELD=NAME " & _
"/MANAGER-FIELD=SupID /DISPLAY-FIELDS=Name, Title " & _
"/CUSTOM-PROPERTY-FIELDS=Title,Location HIDDEN /SHOW-DIVIDER-LINE " & _
"/SYNC-ACROSS-PAGES /HYPERLINK-ACROSS-PAGES"

'fill in args here
objAddOn.Run ("/S-ARGSTR " + orgWizArgs)

'Run the wizard
objAddOn.Run ("/S-RUN")

'Save the document as a web page
Set objAddOn2 = VisApp.Addons.ItemU("SaveAsWeb")

'Add the Web Page Arguments/Preferences
objAddOn2.Run "/QUIET=True /NAVBAR=False /SEARCH=true " & _
"/TARGET=C:\Documents and Settings\SLozano\My Documents\OrgChart.htm"

'Quit Visio and close everything out
VisApp.Quit
Set VisApp = Nothing

End Sub


.
~Oorang

jfournier
03-31-2009, 06:49 AM
You can set the VisApp.AlertResponse to IDNO, meaning that instead of asking if you want to save, Visio will know your answer is No, and will close out without a messagebox.

VisApp.AlertResponse = 7 ' For late binding
VisApp.AlertResponse = IDNO ' For Early binding