Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Jan 2001
    Location
    Bay Area, California, USA
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Set File>Properties through automation (2000 SR1)

    I want to set the file properties (Title, Subject) of an Excel file through automation from a non-Excel VBA client (Word). I can do this in Word as follows

    Dim oWordApp As Word.Application
    Set oWordApp = New Word.Application
    Dim oWordDoc As Word.Document
    Set oWordDoc = New Word.Document
    ...
    Set oWordDoc = oWordApp.Documents.Open("somedoc.doc")
    ...
    oWordDoc.BuiltInDocumentProperties("Title").Value = "Some Title"

    If I try this in Excel, I get runtime error 429 ("ActiveX server can

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Set File>Properties through automation (2000 SR1)

    Klaus, you have to use new or add to create a workbook. Here's the code that you need. Analogous code for Word should work. HTH --Sam<pre>Option Explicit
    Sub Macro1()
    Dim xlApp As New Excel.Application
    Dim xlBook As Excel.Workbook
    Set xlBook = xlApp.Workbooks.Open("c:Test.xls")
    xlBook.BuiltInDocumentProperties("Title").Value = "Testing"
    xlBook.Close SaveChanges:=True
    Set xlBook = Nothing
    Set xlApp = Nothing
    End Sub</pre>

    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  3. #3
    Lounger
    Join Date
    Jan 2001
    Location
    Bay Area, California, USA
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set File>Properties through automation (2000 SR1)

    Thanks, Sam.
    Worked like a charm <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    Klaus

Posting Permissions

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