Createobject Word.application Error 424
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn run time error 424 object required vba more about Stack Overflow the company Business Learn more about hiring developers or posting object required error vba ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack
Excel Vba Runtime Error 424 Object Required Userform
Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up VBA Run-time error 424: Object required with Word document SaveAs up
Runtime Error 424 Object Required Vb6
vote -1 down vote favorite I have an issue with this piece of code I'm writing. When I run the macro it gives me an "Run-time error '424': Object required" on the ActiveDocument.SaveAs filename:="C:\test\test.docx", _ FileFormat:=wdFormatXMLDocument, AddToRecentFiles:=False line. I suppose this has something to do with the word Document and the word window situation, but I don't know how to solve it. Any help would be greatly appreciated! compile error object required vba (After the mentioned line I need to close the word document as well, maybe anyone could help with that too?) Dim objword As Object Dim objDoc As Object Dim fNameAndPath As Variant Dim fNameAndPath2 As Variant fNameAndPath = "C:\test" fNameAndPath2 = "C:\test2" i = 2 While Not IsEmpty(Cells(i, 3)) ' or whevever you want to start If Cells(i, 9) = "End of Probation Per" Then Set objword = CreateObject("Word.Application") objword.Visible = True objword.Documents.Open (fNameAndPath) objword.Activate With objword.ActiveDocument .Bookmarks("EmpName").Range.Text = Cells(i, 2).Value .Bookmarks("EndDate").Range.Text = Cells(i, 11).Value ActiveDocument.SaveAs filename:="C:\test\test.docx", _ FileFormat:=wdFormatXMLDocument, AddToRecentFiles:=False End With Else: Cells(i, 9).Font.Italic = True End If i = i + 1 Wend End Sub excel vba excel-vba word-vba share|improve this question asked Sep 19 '14 at 14:17 Casz146 277 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted You need to fully qualify the object: objWord.ActiveDocument.SaveAs filename:="C:\test\test.docx", _ FileFormat:=wdFormatXMLDocument, AddToRecentFiles:=False Also note that if you haven't set a reference to the Word object library, the constant wdFormatXMLDocument has no value, so you should define it: Const wdFormatXMLDocument As Long = 12 Re your last comment, you can include a cell value for the file name: objWord.ActiveDocument.SaveAs filename:="C:\test\" & cells(i, 2).value & ".docx", _ FileFormat:=wdFormatXMLDocument, AddToRecentFile
for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Ask a Question Ask for Help Receive Real-Time Help Create a Freelance Project
Runtime Error 424 Object Required Excel 2013
Hire for a Full Time Job Ways to Get Help Expand Search runtime error 424 object required vba access 2010 Submit Close Search Login Join Today Products BackProducts Gigs Live Careers Vendor Services Groups Website Testing Store Headlines Experts run time error 424 object required vba access Exchange > Questions > Error 424 opening Word document "Object required" Want to Advertise Here? Solved Error 424 opening Word document "Object required" Posted on 2004-02-26 Visual Basic Classic 1 Verified http://stackoverflow.com/questions/25936076/vba-run-time-error-424-object-required-with-word-document-saveas Solution 4 Comments 2,009 Views Last Modified: 2008-01-16 Here is my code: Dim wdApp As Object Dim wdDoc As Object On Error Resume Next Set wdApp = GetObject(, "Word.Application") If Err.Number <> 0 Then Set wdApp = CreateObject("Word.Application") End If On Error GoTo 0 Set wdDoc = wdApp.Documents.Open(GetTemplatePath & "\" & TemplateName & ".doc") GetTemplatePath returns a string with a path. https://www.experts-exchange.com/questions/20899728/Error-424-opening-Word-document-Object-required.html TemplateName is fed into the procedure with a string for an existing file. When I get to the last statement, Set wdDoc, I get Error 424: Object required. I don't have any trouble with doing Documents.Add. I also have a webBrowser object hosting a Word document, and I don't have any trouble getting that to open existing documents. 0 Question by:solinox Facebook Twitter LinkedIn Google LVL 9 Best Solution byp_sie First make sure that GetTemplatePath & "\" & TemplateName & ".doc" is a valid filename. I mean, check if GetTemplatePath does not end with a "\"... And what if you change Set wdDoc = wdApp.Documents.Open(GetTemplatePath Go to Solution 4 Comments LVL 9 Overall: Level 9 Visual Basic Classic 9 Message Accepted Solution by:p_sie2004-02-26 First make sure that GetTemplatePath & "\" & TemplateName & ".doc" is a valid filename. I mean, check if GetTemplatePath does not end with a "\"... And what if you change Set wdDoc = wdApp.Documents.Open(GetTemplatePath & "\" & TemplateName & ".doc") to Set wdDoc = wdApp.Documents.Add What happens then? 0 LVL 69 Overall: Level 69 Visual Basic Classic 32 M
Forums Excel Questions Run-time error 424: Object Required Results 1 to 7 of 7 Run-time error 424: Object RequiredThis is a discussion on Run-time error 424: Object Required within the Excel http://www.mrexcel.com/forum/excel-questions/804841-run-time-error-424-object-required.html Questions forums, part of the Question Forums category; Getting a run time object required error with this code (bolded below) and cannot figure out why! any help would ... LinkBack LinkBack URL About LinkBacks Bookmark & Share Digg this Thread!Add Thread to del.icio.usBookmark in TechnoratiTweet this thread Thread Tools Show Printable Version Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Sep 11th, 2014,11:53 AM object required #1 hlg0035 New Member Join Date Sep 2014 Posts 13 Run-time error 424: Object Required Getting a run time object required error with this code (bolded below) and cannot figure out why! any help would be appreciated My variables for the saved word document code have previously been declared. Dim UserId As String UserId = Sheets("QuantienEvaluations").Range("M5").Value2 Set WrdApp = CreateObject("Word.Application") WrdApp.Visible = True If Sheets("QuantienEvaluations").Range("A2") = "QuantienAerisOnly" time error 424 Then Set WrdDoc = WrdApp.Documents.Open("C:\Users\" & UserId & "\Desktop\Quantien With Aries Only.docx") If Sheets("QuantienEvaluations").Range("A2") = "QuantienAerisCertus" Then Set WrdDoc = WrdApp.Documents.Open("C:\Users\" & UserId & "\Desktop\Quantien With Aeris and Certus.docx") WrdDoc.SaveAs2 Filename:= _ "C:\Users\" & UserId & "\Desktop\ " & CustomerName & " " & City & " " & State & " " & CustomerNumber & " " & "Quantien Evaluation Agreement" & " " & Month(Now()) & "." & Day(Now()) & "." & Year(Now()) & ".docx" _ , FileFormat:=13, LockComments:=False, _ Password:="", AddToRecentFiles:=True, WritePassword:="", _ ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _ SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _ False, CompatibilityMode:=14 Share Share this post on Digg Del.icio.us Technorati Twitter Reply With Quote Sep 11th, 2014,11:57 AM #2 Norie Board Regular Join Date Apr 2004 Location Stirling Posts 69,951 Re: Run-time error 424: Object Required Has a Word document definitely been opened? Share Share this post on Digg Del.icio.us Technorati Twitter If posting code please use code tags. Reply With Quote Sep 11th, 2014,12:02 PM #3 hlg0035 New Member Join Date Sep 2014 Posts 13 Re: Run-time error 424: Object Required Word has opened but not the specific document. Originally Posted by Norie Has a Word document definitely been opened? Share Share this post on Digg Del.icio.u