Compile Error Expected End With Vba
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss
Vba Compile Error Expected =
the workings and policies of this site About Us Learn more about vba compile error expected array Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow
Compile Error Expected Expression Vba
Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each excel vba compile error expected = other. Join them; it only takes a minute: Sign up VBA Error: “Compile error: Expected End Sub” up vote 1 down vote favorite Trying to pass "GetFullNamePDF()" to the Filename attribute, but getting the following error: "Compile error: Expected End Sub" Sub PrintPDF() Function GetFullNamePDF() As String GetFullNameCSV = Replace(ThisWorkbook.FullName, ".xlsm", ".pdf") End Function ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ "GetFullNamePDF()", visual basic compile error expected end of statement Quality:=xlQualityStandard, IncludeDocProperties _ :=True, IgnorePrintAreas:=False, OpenAfterPublish:=False End Sub I know nothing about VBA, and got the above code from a question I asked yesterday, but was unable to test at the time. Guessing the error has to do with the function, since the code works without the function added and the filepath/name hard coded. Idea of the code is to dynamically use the filename of itself to name the path and file for the PDF. If you have any questions, just comment -- thanks! excel vba share|improve this question asked Dec 17 '10 at 15:40 blunders 1,58272759 add a comment| 3 Answers 3 active oldest votes up vote 3 down vote accepted You can't nest a function inside a procedure. You need to move it above: Function GetFullNamePDF() As String GetFullNameCSV = Replace(ThisWorkbook.FullName, ".xlsm", ".pdf") 'This should be GetFullNamePDF = Replace(ThisWorkbook.FullName, ".xlsm", ".pdf") End Function Sub PrintPDF() 'Remove the quotes from GetFullNamePDF ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ GetFullNamePDF(), Quality:=xlQualityStandard, IncludeDocProperties _ :=True, IgnorePrintAreas:=False, OpenAfterPublish:=False End Sub share|improve this answer answered Dec 17 '10
Forum Microsoft Office Application Help - Excel Help forum Excel Programming / VBA / Macros vb error compile error Expected End with To get replies by our experts at nominal charges, follow
Compile Error Expected End Sub Excel Vba
this link to buy points and post your thread in our Commercial Services compile error block if without end if forum! Here is the FAQ for this forum. + Reply to Thread Results 1 to 5 of 5 vb error
Compile Error Expected End Of Statement
compile error Expected End with Thread Tools Show Printable Version Subscribe to this Thread… Rate This Thread Current Rating Excellent Good Average Bad Terrible Display Linear Mode http://stackoverflow.com/questions/4472095/vba-error-compile-error-expected-end-sub Switch to Hybrid Mode Switch to Threaded Mode 11-28-2010,06:10 PM #1 00Able View Profile View Forum Posts Forum Contributor Join Date 11-17-2010 Location Pittsburgh, PA MS-Off Ver Excel 2003, 2007, 2010 Posts 244 vb error compile error Expected End with So with a lot of help, I have added a calendar to a userform, however, now when I test the userform to make sure it http://www.excelforum.com/showthread.php?t=754768 works, I get an error that reads "COMPILE ERROR: EXPECTED END WITH" as soon as I hit Submit. I am not sure how to fix this, any suggestions would be appreciated? I would copy the code, but as I am not sure where the error is derived from I don't believe copy all the code would be beneficial. Last edited by 00Able; 11-28-2010 at 07:07 PM. Register To Reply 11-28-2010,06:43 PM #2 davesexcel View Profile View Forum Posts Visit Homepage Forum Guru Join Date 02-19-2006 Location Regina MS-Off Ver XL 2010,2016 Posts 9,372 Re: vb error compile error Expected End with Please Login or Register to view this content. where is the End with? , Excel MVP Xlorate.com, Selection Codes, YouYube Channel Register To Reply 11-28-2010,06:43 PM #3 solnajeff View Profile View Forum Posts Forum Contributor Join Date 04-21-2007 Location Lima, Peru MS-Off Ver 2000, 2007, 2010 Posts 674 Re: vb error compile error Expected End with Hi You need to complete any With statement with and End With statement after your last line of relevant code. Regards Jeff Register To Reply 11-28-2010,06:44 PM #4 Richard Buttrey View Profile View For
+ Ask a Question Need help? Post your question and get tips & solutions from a community https://bytes.com/topic/visual-basic/answers/907558-how-fix-compile-error-expected-end-sub-vba-macro of 418,469 IT Pros & Developers. It's quick & easy. How to fix "Compile error: Expected End Sub" in VBA Macro? P: 1 Dorota Prywata Hi, I need help with VBA Macro for Auto-filter to high lite a header plp advice as per below course a I got Compile error: Expected End Sub ? Expand|Select|Wrap|Line Numbers SubMacro1() FunctionFilterOn(myCellAsRange)AsBoolean OnErrorResumeNext WithmyCell.Parent.AutoFilter With.Filters(myCell.Column-.Range.Column+1) compile error If.OnThenFilterOn=True EndWith EndWith EndFunction EndSub Thanks, D Feb 3 '11 #1 Post Reply Share this Question 1 Reply Expert Mod 2.5K+ P: 2,543 Stewart Ross You can't define a function (lines 3-10) WITHIN the definition of a SUB (lines 1 and 12). You can CALL the function from the sub, but they must be separately defined. -Stewart Feb 3 '11 #2 reply compile error expected Message Cancel Changes Post your reply Join Now >> Sign in to post your reply or Sign up for a free account. Similar topics How to fix "Compile Error Expected: end of statement" in a query? How to fix error when executing macro: "Compile Error Variable not defined"? Delete Record Button and Getting a "compile error" Right turns to RIGHT and I get "Compile Error -Expected Array "on error resume next" does not work! "instantiated from here" compile error when using template "Use of possibly unassigned field" compile error What would cause"Compile error in hidden module" docmd.RunSQL Update records in table how can I get rid of the "You are about to update" message Browse more Visual Basic 4 / 5 / 6 Questions on Bytes Question stats viewed: 8200 replies: 1 date asked: Feb 3 '11 Follow this discussion BYTES.COM © 2016 Formerly "TheScripts.com" from 2005-2008 About Bytes | Advertise on Bytes | Contact Us Sitemap | Visual Basic 4 / 5 / 6 Answers Sitemap | Visual Basic 4 / 5 / 6 Insights Sitemap Follow us to get the Latest Bytes Updates