+ Reply to Thread
Results 1 to 10 of 10

Reading document properties for Excel and Word documents

  1. #1
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Reading document properties for Excel and Word documents

    To read a document property for a closed Excel file, the code below can be used. Test by creating an Excel file "MyExcelFile.xlsx" in C drive.
    Is there an equivalent method for a Word document?

    Please Login or Register  to view this content.

  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: Reading document properties for Excel and Word documents

    You're not really reading a property of a closed file if you open it. Word Document objects have the same properties, so
    Please Login or Register  to view this content.
    although you can read saved time of a file without opening using filedatetime
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Reading document properties for Excel and Word documents

    I'm getting an error when I use the first module in #2:
    Run-time error '-2147467259 (80004005)':
    Automation error
    Unspecified error

    With the second method, it does work ... however I need to also extend to other properties such as Title and Subject, which I think cannot be done this way?

  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: Reading document properties for Excel and Word documents

    The longer version of #2
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Reading document properties for Excel and Word documents

    I still get the same error message.
    You can tell the file is opened as you can see the lighter colored "~$WordFile.docx". This has to be opened and closed manually to try again.
    If I replace MsgBox odoc.BuiltinDocumentProperties("Last save time") with MsgBox FileDateTime("C:\MyWordFile.docx"), it will work.

  6. #6
    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: Reading document properties for Excel and Word documents

    Is your Word application working normally if you run it manually?

  7. #7
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Reading document properties for Excel and Word documents

    Yes, it is working normally as far as I know.
    Last edited by Un-Do Re-Do; 01-30-2018 at 11:35 AM.

  8. #8
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Reading document properties for Excel and Word documents

    I will try in another computer tomorrow.

  9. #9
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Reading document properties for Excel and Word documents

    @xlnitwit, I made just one small change to the code in post #4.
    set odoc = oword.documents.open("C:\MyWordFile.docx") is changed to Set oDoc = oWord.Documents.Open(FileName:="C:\MyWordFile.docx")
    This seems to work now.
    Thanks for your help.

    Please Login or Register  to view this content.

  10. #10
    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: Reading document properties for Excel and Word documents

    That is curious indeed. There should never be a need to use named arguments.

+ 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. [SOLVED] Code help: Selecting documents into one Word document via Excel
    By jk. in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2015, 12:21 PM
  2. Split a single word document into multiple word documents
    By CaptainCool in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2014, 03:31 AM
  3. Batch Compile 100+ multiple word documents into a single word document
    By JamesFrames8 in forum Word Formatting & General
    Replies: 4
    Last Post: 04-03-2014, 08:49 PM
  4. Modifying Word Document Properties using Mail Merge and data in Excel
    By veejar in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-28-2012, 01:29 AM
  5. VBA To Return Custom Properties Of A Word Document
    By stefanchik in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-15-2010, 06:02 PM
  6. how to send documents from document imaging to word?
    By JBHarriman in forum Excel General
    Replies: 0
    Last Post: 01-30-2005, 04:06 PM
  7. [SOLVED] [SOLVED] Accessing custom document properties in Word?
    By quartz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-18-2005, 11:06 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