Still getting error 462 every other time I run the macro. not sure how to beat this error.
On Monday, October 21, 2013 8:21:02 AM UTC-7, Justin Pulley wrote: > > I don't know how to mark something uncompleted. > > The code works every other time. > > <code> > > Sub CreateReportPDF() > Dim wdapp As Word.Application > Dim wddoc As Word.Document > > Run CopyData > > Set wdapp = Word.Application > Set wddoc = wdapp.documents.Add > > Application.ScreenUpdating = False > > wdapp.Visible = True > With wddoc.PageSetup > .Orientation = wdOrientLandscape > .PageWidth = InchesToPoints(17) > .PageHeight = InchesToPoints(11) > End With > > For Each sh In Worksheets(Array("Power Report", "ATS Data")) > ThisWorkbook.Sheets(sh.Name).UsedRange.Copy > > With wdapp > .Visible = True > .Selection.Paste > End With > Next > > Application.CutCopyMode = False > Application.ScreenUpdating = True > > wddoc.SaveAs2 MyDocuments & "\" & "Power Report " & Format((Date), "mm - > dd - yy") & Format((Time), " hhmm") 'change file name as u like > MsgBox "The power report has been generated and saved to your My Documents > Folder" > > wddoc.Close > wdapp.Quit > > Set wddoc = Nothing > Set wdapp = Nothing > > End Sub > > </code> > > The first time you run the routine it works no issues. The next time you > run the routine it fails on error 462. Then you can run it again and it's > fine. Error 462 occurs every other time. I have tried every fix I can > find for that error and none of it seems to work. There are some sites > that claim you should not use a With command when using a word application > object. > > > -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros. For more options, visit https://groups.google.com/groups/opt_out.