+ Reply to Thread
Results 1 to 5 of 5

Object doesn't support this property or method - word object

Hybrid View

  1. #1
    Registered User
    Join Date
    02-06-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2016
    Posts
    50

    Object doesn't support this property or method - word object

    Hey guys... I've got some code that I'm upgrading but it doesn't like my word object reference at the bottom.

    For Each Doc In Documents
    Doc.Footers(wdHeaderFooterPrimary).Range.Text = Application.UserName & Date & jobnumber
    Doc.PrintOut
    Doc.Footers(wdHeaderFooterPrimary).Range.Text = ""
    Next Doc


    Doc.PrintOut works fine.

    here's my whole code:

    Sub PrintAllDocuments()
        Dim copies As Variant
        Dim jobnumber As String
        
        sPrompt = "How many copies?"
        sTitle = "Awesome Print All Macro"
        sDefault = 1
        
        copies = InputBox(sPrompt, sTitle, sDefault)
        
        If copies = Empty Then
            Exit Sub
        Else
        
            For i = 1 To copies
            jPrompt = "Job Number:"
            jTitle = "Awesome Print All Macro"
            jDefault = ""
            
            jobnumber = InputBox(jPrompt, jTitle, jDefault)
            
            ' Step through the open document windows
                For Each Doc In Documents
                    Doc.Footers(wdHeaderFooterPrimary).Range.Text = Application.UserName & Date & jobnumber
                    Doc.PrintOut
                    Doc.Footers(wdHeaderFooterPrimary).Range.Text = ""
                Next Doc
            Next i
        End If
    End Sub
    All I need is for these objects to print out on my document
    Application.UserName & Date & jobnumber
    If anyone knows a more efficient way to do this besides editing the footer, that would be a welcome option as well.

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Object doesn't support this property or method - word object

    Hi,

    Is this code in Word or in Excel? If it's in Excel, you need to get a Word.Application instance before you can start looping through documents.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Registered User
    Join Date
    02-06-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2016
    Posts
    50

    Re: Object doesn't support this property or method - word object

    Quote Originally Posted by xlnitwit View Post
    Hi,

    Is this code in Word or in Excel? If it's in Excel, you need to get a Word.Application instance before you can start looping through documents.
    This is actually in Word... everything has started to blur together... but I'm not opposed to running the script from excel, as long as I can keep the same functionality.

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Object doesn't support this property or method - word object

    I think this is in the wrong place then.

    As far as I know a document doesn't have a Footers property- that belongs to the Section object, so you would need another loop
                For Each Doc In Documents
                    for each sec in Doc.Sections
                       Sec.Footers(wdHeaderFooterPrimary).Range.Text = Application.UserName & Date & jobnumber
                    Next sec
                    Doc.PrintOut
                    for each sec in Doc.Sections
                       Sec.Footers(wdHeaderFooterPrimary).Range.Text = ""
                    Next sec
                Next Doc

  5. #5
    Registered User
    Join Date
    02-06-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2016
    Posts
    50

    Re: Object doesn't support this property or method - word object

    OK, that worked. I was able to add the section parameter in line without doing a loop (there's only one section in each of my documents).

    Thanks, xlnitwit!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Error Object doesn't support this property or method
    By rongil20 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-14-2015, 06:57 AM
  2. Object doesn't support this property or method
    By Apple1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-30-2014, 12:09 AM
  3. Object doesn't support this property or method
    By amartino44 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2013, 10:05 AM
  4. object doesn't support this property or method
    By teowchy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-16-2013, 03:16 AM
  5. error '438', Object doesn't support this property or method.
    By ironmonkey888 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-23-2010, 09:23 AM
  6. [SOLVED] Object doesn't support this property or method
    By davegb in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-29-2007, 08:23 AM
  7. [SOLVED] 438 - Object doesn't support this property or method
    By Revtim in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-12-2005, 05:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1