Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-12-2017, 10:28 AM
ashg75 ashg75 is offline compile error expected end sub Windows 7 64bit compile error expected end sub Office 2013
Novice
compile error expected end sub
 
Join Date: Jun 2017
Posts: 11
ashg75 is on a distinguished road
Default compile error expected end sub


Hello, I know very little VBA but I am working on a project. I received help from another user and the code he gave me keeps returning "compile error: Expected End Sub" error message. I have the "End Sub" at the end of the code. What should I do?
Attached Images
File Type: jpg Capture.1.JPG (72.7 KB, 14 views)
File Type: jpg Capture.2.JPG (73.3 KB, 14 views)
Reply With Quote
  #2  
Old 07-12-2017, 08:58 PM
gmayor's Avatar
gmayor gmayor is offline compile error expected end sub Windows 10 compile error expected end sub Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The error is caused by having two macro name rows. The first one has no corresponding end sub and should be deleted
Code:
Sub ContentControlOnEnter()
Private Sub Document_ContentControlOnEnter(ByVal oCC As ContentControl)
There should also be an
Code:
End Select
line after
Code:
Next lnglndex
There is also an error in the line
Code:
If Not "IsNull(arrData(0, lnglndex" Then
which I suggest should be
Code:
If Not IsNull(arrData(0, lnglndex)) Then
The variable arrData has not been declared. Put Option Explicit at the top of your VBA modules to force the declaration of variables, which will make errors easier to find. You can set this as the default in VBA Tools > Options > Editor. It will then add Option Explicit when you add a module to your projects.

This looks like code from my old friend Greg Maxey. Check the source of the code again and make sure you copy it correctly and don't screw it up when you make changes.

When posting code copy and paste the code from the editor, select it and use the # button to add CODE tags.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 07-13-2017, 07:08 AM
ashg75 ashg75 is offline compile error expected end sub Windows 7 64bit compile error expected end sub Office 2013
Novice
compile error expected end sub
 
Join Date: Jun 2017
Posts: 11
ashg75 is on a distinguished road
Default

Yes, it def is one of his codes he has helped me with. Thanks!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile error in hidden module: Tools rafikiphoto Excel 2 01-16-2023 07:40 AM
compile error expected end sub Compile error in Module ksigcajun Word VBA 2 04-08-2015 06:44 AM
compile error in save code tintin007 Word VBA 8 11-18-2014 03:49 AM
Compile error: sub or function not defined.. xena2305 Excel Programming 0 08-02-2011 10:17 AM
compile error in Word raco Word 0 09-28-2010 12:40 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:32 AM.


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