Solved

Why? does cmdButton (ActiveX) _click, that drives NO procedure, interfere with independent sub: AlertResponse = 1; ThisDocument.Saved = True; ThisDocument.Close

Posted on 2014-03-28
8
305 Views
Last Modified: 2016-08-29
During a pilot expt in  VBA  to test automated closure of a visio doc (with and without ThisDocument.Save /ThisDocument.Saved=1 ), I set up an ** activeX command button ** on the visio drawing page to drive  changes in variables (eg shape.text and variables within shapesheet User Sections). This was to provide a test the effectiveness of the .Save method and .Saved = 1 property (code below).

I was surprised to find that clicking an ** activeX command button **, just once, stopped Sub CloseNoSave() from functioning (the doc did not close). This occurred even when the sub for the activeX button_click event contained NO content code (eg, no call to drive another procedure).

The activeX button did not affect the function of Sub CloseWithSave().

I found that UserForm cmd buttons had NO such effect, and did successfully drive Sub CloseWithSave()  and Sub CloseNoSave() from the respective _Click event procedures in the UserForm code.

Though the userForm approach is my FIRST choice approach, can you tell me what the problem is with the ActiveX button, and how to avoid it (whilst retaining the service of the activeX button when it is essential)?

[Transfer of Sub CloseNoSave() into the content code of the activeX button_click event sub made no improvement.]

THE CODE follows for "Close With Save" and "Close No Save".
UserForm1 provided a check that userForm cmd buttons did not interfer with  "Close With Save" and "Close No Save".

Sub CloseWithSave()
If Not UserForm1 Is Nothing Then Unload UserForm1
                                                              Debug.Print "Close With Save"
    Application.AlertResponse = 1
    ThisDocument.Save
    ThisDocument.Close
    'Application.Quit
End Sub

Sub CloseNoSave()
If Not UserForm1 Is Nothing Then Unload UserForm1
                                                             Debug.Print "Close No Save"
    Application.AlertResponse = 1
    ThisDocument.Saved = True
    ThisDocument.Close
    'Application.Quit
End Sub

Sub showForm()
    UserForm1.Show
End Sub
0
Comment
Question by:Kelvin4
  • 4
  • 4
8 Comments
 
LVL 29

Expert Comment

by:gowflow
ID: 39962252
Could you pls post the whole code ?
gowflow
0
 

Author Comment

by:Kelvin4
ID: 39962774
gowFlow, thank you. I've uploaded the visio vsdm file to EE stuff, and received this receipt:

-----------------
Your file has successfully been uploaded!
To download the file, you must be logged into EE-Stuff. Here are two pages that will display your file, if logged in:

View all files for Question ID: 28399775
https://filedb.experts-exchange.com/incoming/ee-stuff/8344-Close-and-Save-visio-doc-27032.vsdm

Direct link to your file
https://filedb.experts-exchange.com/incoming/ee-stuff/8344-Close-and-Save-visio-doc-27032.vsdm

-----------------
Kelvin
0
 
LVL 29

Expert Comment

by:gowflow
ID: 39962869
Oops you mentioned the Excel zone but your file is a Visio ? I did not chk the link. Is your code in Visio or Excel ?
gowlfow
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:Kelvin4
ID: 39963130
The code is visio 2013. Do you deal with visio? If not, I can transfer it to excel and check if the activeX effect persists.
Kelvin
0
 
LVL 29

Accepted Solution

by:
gowflow earned 500 total points
ID: 39963361
Sorry but do not have Visio on my machine. If you transfer it to Excel try to upload the file here you can see Attach File in the window when you enter you comments and it will show here not as a link like you posted before.
Tks/gowflow
0
 

Author Comment

by:Kelvin4
ID: 39963426
gowflow,

I have checked out if this ActiveX effect occurs in Excel, and it does NOT!
The method for turning off Alerts differs between the two apps:

Excel uses Application.DisplayAlerts = False to turn off Alerts, whereas
Visio uses Application.AlertResponse = 1  to avoid Alerts (? saying 'its done, so dont do it'..?)

EE have yet to enable Visio 2013 files to be uploaded as one would prefer within this interface, hence the round about route via EE Stuff.

This question should have been more clearly labelled, with 'VISIO' in the title; I'll edit and submit as a new question.  

I sign off this question with thanks for your quick response, and look forward to the opportunity of future contact.

Kelvin
0
 

Author Closing Comment

by:Kelvin4
ID: 39963427
with compliments
Kelvin4
0
 
LVL 29

Expert Comment

by:gowflow
ID: 39963450
well tks your response but in Visio it shouldn't be different from Excel try
Application.AlertResponse = False

and by the way this is not what prevent the execution of the ActiveX in Excel it is this instruction the will not allow execution of any event until the current one is completed
Application.EnableEvents = False

Usually in Excel when we have a routine that we do not want any interference with other subroutine we do it this way:

Sub MySub

---> Disable Events
With Application
    .EnableEvents = False
    .ScreenUpdating = False
    .DisplayAlerts = False
End With

...
your code 
...

'---> Enable Events
With Application
    .EnableEvents = True
    .ScreenUpdating = True
    .DisplayAlerts = True
End With

End Sub

Open in new window


gowflow
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ability to add structure to Visio diagrams using containers, lists and callouts is one of my favorite features in Visio 2010. In this article we’ll examine lists. We’ll explore containers and callouts in separate articles. Prior to reading th…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question