Quantcast
Channel: General Office Development forum
Viewing all articles
Browse latest Browse all 2257

VBA code working in code window but not from the powerpoint application

$
0
0

Hello,

I created the below vba code for toggling the chart scale to auto or fixed. I used a wscript message box. The code is working from the code window. But If I run from the button from powerpoint window, the wscript message box doesn't close automatically with the timer given 2 seconds. Below is my code. Thanks for your great help.

Sub AxisFixedorAuto()
Const ShowDurationSecs As Integer = 2
Dim wsWShell As Object
Dim Rslt As Integer

With ActiveWindow.Selection.ShapeRange(1).chart.Axes(xlValue)
If .MinimumScaleIsAuto = False And .MaximumScaleIsAuto = False And .MajorUnitIsAuto = False And .MinorUnitIsAuto = False Then
    .MinimumScaleIsAuto = True
    .MaximumScaleIsAuto = True
    .MajorUnitIsAuto = True
    .MinorUnitIsAuto = True
    
    Set wsWShell = CreateObject("WScript.Shell")
    Rslt = wsWShell.PopUp("Scale - Auto", ShowDurationSecs, "Chart Scale", 0)

- 'The above code works, if it is run in codewindow by F5 or F8. But if I run by clicking the button from powerpoint, the msgbox, doesn't close after the duration of 2 secs.

Else
    .MinimumScaleIsAuto = False
    .MaximumScaleIsAuto = False
    .MajorUnitIsAuto = False
    .MinorUnitIsAuto = False
End If
Set wsWShell = Nothing
End With
End Sub

Thanks and Regards,
balumail75.


Viewing all articles
Browse latest Browse all 2257

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>