Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2004

Tip: Looking for answers? Try searching our database.

Run Time Error 5825 - Object Deleted

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ac-Deucy - 02 Nov 2004 18:00 GMT
I have some VBA macro code below for Word 2003 (not the entire subroutine).  
The ActiveDocument.Variable("Document Number") is defined earlier in another
subroutine, and the user is prompted for it, among other document variables.  
Unfortunately, if the user leaves it blank, the macro below gives the Run
Time Error 5825; debug shows that processing stops at the line

If VProcNum = ""

VProcNum is not NULL, ISERROR of ISEMPTY.  How can I fix the macro and
prevent getting this error message?

THANKS!

    here's the macro...

Sub ManualTitle()
'
' ManualTitle Macro
'
   Dim VProcNum
'
' Create variable for Procedure Number; if it is empty, warn the user
'
  Set VProcNum = ActiveDocument.Variables("Document Number")
  If VProcNum = "" Then
       Style = vbOKOnly + vbInformation + vbDefaultButton1
       Response = MsgBox("Without a Document Number, some header variables
will not be populated ", Style, "No Document Number")
   End If
Malcolm Smith - 02 Nov 2004 18:37 GMT
The problem is that you're mixing up types.

ActiveDocument.Variables("Document Number")

will return a Variable object.   You are testing for a string.    I also
note that you haven't defined what sort of type VProcNum is in your Dim
statement.

Once you've set them all to the same type then you could do:

 If VProcNum is Nothing then
 
But you'll have to make sure that the Document Variable does exist first.  
I would write a small function which goes through the document's Variables
and then checks to see if the variable exists.

- Malc
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.