Results 1 to 3 of 3

Thread: Get/Set Office Document Props w/ VB 6.0

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2003
    Posts
    3

    Get/Set Office Document Props w/ VB 6.0

    Hello! I am new to vbforums.com. A friend told me you guys would be able to help me!

    I am an intern at a company and one of my projects involves modifying an application which generates a letter in Microsoft Word. The modification I need to make involves me setting the document's Properties field "Keywords" to information received in the application.

    Right now the lines of code I have are

    Dim oBuiltInProps as Object

    oBuiltInProps = wrdDoc.BuiltInDocumentProperties
    oBuiltInProps.Item("Keywords").Value = SSN

    The application doesn't throw an accept or anything. It just doesn't do what I want it to. I was hoping you guys might have some suggestions as to how I can fix this or suggestions on what I can do to make it work! Anything and everything is helpful! Thanks!
    "Computer Science is no more about computers that Astronomy is about telescopes" ~E.W. Dijkstra

  2. #2
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    Is that wrd or wd???

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim myRange As Range
    3.     Dim sSearchfor As String
    4.  
    5.     If objWord Is Nothing Then
    6.         Set objWord = CreateObject("Word.Application")
    7.     Else
    8.         Set objWord = GetObject(, "Word.Application")
    9.     End If
    10.     DoEvents
    11.     Set wd = objWord.Documents.Open("c:\Test.doc")
    12.     MsgBox wd.BuiltInDocumentProperties(wdPropertyTitle)
    13.     MsgBox wd.BuiltInDocumentProperties(wdPropertySubject)
    14.     MsgBox wd.BuiltInDocumentProperties(wdPropertyManager)
    15.     MsgBox wd.BuiltInDocumentProperties(wdPropertyComments)
    16.     MsgBox wd.BuiltInDocumentProperties(wdPropertyLastAuthor)
    17.    
    18.     objWord.Visible = True
    19. End Sub

  3. #3
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046
    You will have an easier time if you Set a reference to Msft Word Object Library then :

    dim objWord as New Word.Application

    The advantage being that intellisense will help you out and youll have access to word constants.

Posting Permissions

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



Click Here to Expand Forum to Full Width