OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 26-02-2012, 19:48
noj noj is offline
Join Date: Oct 2011
Location: Sydney
Posts: 31
Default SelectionChange Event question

I am getting a Runtime Error 91 when I close a document (just the document - the application is still open). It doesn't like the following line of code:

If Application.ActiveDocument.Active = False Then Exit Sub
This is the whole lot:

Private Sub GlobalMacroStorage_SelectionChange()

    Dim sr As ShapeRange
    Dim col As String
    Dim colname As OptionButton
    Dim intens As Integer
    Dim siz As Integer
    Set sr = ActiveSelectionRange
    If Application.ActiveDocument.Active = False Then Exit Sub

    If Neon.Visible = False Then
        Exit Sub
        Neon.RU.Value = False
        Neon.RU.ForeColor = &H80000011
        Neon.RE.Value = False
        Neon.RE.ForeColor = &H80000011
        Neon.OG.Value = False
        Neon.OG.ForeColor = &H80000011
        Neon.GO.Value = False
        Neon.GO.ForeColor = &H80000011
        Neon.YE.Value = False
        Neon.YE.ForeColor = &H80000011
        Neon.GR.Value = False
        Neon.GR.ForeColor = &H80000011
        Neon.TU.Value = False
        Neon.TU.ForeColor = &H80000011
        Neon.CY.Value = False
        Neon.CY.ForeColor = &H80000011
        Neon.LI.Value = False
        Neon.LI.ForeColor = &H80000011
        Neon.BL.Value = False
        Neon.BL.ForeColor = &H80000011
        Neon.DE.Value = False
        Neon.DE.ForeColor = &H80000011
        Neon.PU.Value = False
        Neon.PU.ForeColor = &H80000011
        Neon.MA.Value = False
        Neon.MA.ForeColor = &H80000011
        Neon.HO.Value = False
        Neon.HO.ForeColor = &H80000011
        Neon.WH.Value = False
        Neon.WH.ForeColor = &H80000011
        Neon.WA.Value = False
        Neon.WA.ForeColor = &H80000011
        If sr.Count = 0 Then Exit Sub
        If sr(1).IsSimpleShape = True Then Exit Sub
        If Left(sr(1).Name, 4) <> "neon" Then
            Exit Sub
            col = Mid(sr(1).Name, 9, 2)
            Set colname = Neon(Mid(sr(1).Name, 9, 2))
            intens = Mid(sr(1).Name, 11, 3)
            siz = Mid(sr(1).Name, 14, 3)
            Neon.ChangeTest = "Update"
            Neon.Colour = col
            colname.ForeColor = &H8000000E
            Neon.GlowIntensitySlider = intens
            If intens = 0 Then
                Neon.GlowIntensity = "No Glow"
                Neon.GlowIntensity = intens & "%"
            End If
            Neon.GlowSizeSlider = siz
            Neon.GlowSize = siz & "mm"
        End If
    End If
End Sub
Can anyone tell me how to stop errors when the user closes a document?

Also, on a kind-of related matter (is it bad form to ask two questions in one post?), can anyone tell me how to give the main application window back the focus after the above code changes some values on my userform? Instead of the form being selected still?

Thanks heaps.
Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
example code for using querydocumentclose event aakkaarr CorelDRAW/Corel DESIGNER VBA 1 03-05-2009 15:56
Use event in C# application! TheFez CorelDRAW/Corel DESIGNER VBA 0 05-06-2008 05:07
Event Categories Vegas Calendar Wizard 4 08-07-2005 15:08
Dirty related event in CD 12? barnold CorelDRAW/Corel DESIGNER VBA 1 26-07-2004 00:28
How can I catch the OnClose event? Elie CorelDRAW CS 2 01-04-2004 01:20

All times are GMT -5. The time now is 22:24.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com