Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-16-2022, 10:31 AM
BrianHoard BrianHoard is offline Proper use of lbl_Exit: Windows 10 Proper use of lbl_Exit: Office 2019
Advanced Beginner
Proper use of lbl_Exit:
 
Join Date: Jul 2022
Location: Haymarket, VA USA
Posts: 85
BrianHoard is on a distinguished road
Default Proper use of lbl_Exit:

As our small team learns VBA, we get a lot of info from the folks on this forum and their websites. I like to understand every line of code, and not blindly copy/paste from the internet.



As I review several of our scripts, I keep seeing this "lbl_Exit:" From my Windows cmd scripting, this looks like it may be the target for a GOTO command? But I'm seeing it just listed in the script with nothing else pointing to it. Which I'm guessing will just run the commands under this label when it appears in the script.

Can someone explain what this is about, or where I can learn more about it, and even if I need it at all?

Here's is one of several similar scripts we've created that uses lbl_Exit: But nothing in the script calling it.

I'm guessing setting a variable to Nothing clears it, which seems like a good thing to do. Not sure if that is necessary, as Exit Sub and End Sub would probably do that anyways, right?

Code:
Sub bhh_removeCrossRefs()
  ' Do what Ctrl shift F9 does, removing cross-references.
  
  Dim i as Integer
  Dim oStory As Range
  For Each oStory In ActiveDocument.StoryRanges
    For i = oStory.Fields.Count To 1 Step -1
      If oStory.Fields(i).Type = wdFieldNoteRef Then
        Debug.Print (oStory.Fields(i).Type)
        oStory.Fields(i).Unlink
      End If
    Next i
  Next oStory
  
  lbl_Exit:
    Set oStory = Nothing
    Exit Sub
    
End Sub ' bhh_removeCrossRefs
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Proper use of lbl_Exit: Making exceptions to PROPER Chayes Excel Programming 8 06-05-2018 07:19 AM
Proper use of lbl_Exit: Need a proper Office 2010 Flobiwan Office 2 04-23-2017 04:27 AM
Button does not generate proper colors? cloudforgiven Excel 10 12-22-2016 09:57 PM
proper snoforlife Excel Programming 0 01-26-2016 02:16 PM
Proper Text Format sufian,naeem Excel 1 05-05-2014 05:59 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:34 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft