Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Accessing Word Document Properties

Posted on 2001-09-07
9
Medium Priority
?
615 Views
Last Modified: 2008-02-20
I have a form that opens Word documents within a web browswer control.

Having a reference to the Word Object Library, I can open the Properties dialog by using:
"mDoc.Application.Dialogs(wdDialogFileSummaryInfo).Show"

My question is can the data in this dialog be accessed via vb code so that I can update it with data from an Access db, without the user seeing it?
0
Comment
Question by:gammbro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 12

Accepted Solution

by:
roverm earned 200 total points
ID: 6465761
First get a reference to Word:

On Error Resume Next
Set oWord = GetObject("", "Word.Application")
If Err.Number <> 0 Then
  MsgBox "error getting word"
  Exit Sub
End If

Then retreive or set the prop's like this:

   Sub SetSummaryInfo ()
      Dim dp As Object
      Dim sTitle As String
      If oWord.Documents.Count > 0 Then
         Set dp = oWord.Dialogs(wdDialogFileSummaryInfo)
         ' Retrieve value of "Title" into a variable.
         sTitle  = dp.Title
         ' Set "Title" to a new value.
         dp.Title = "My Title"
         ' Set the value without showing the dialog.
         dp.Execute
         ' Save the changes
         oWord.ActiveDocument.Save
      End If
   End Sub

Set oWord = Nothing

D'Mzzl!
RoverM
0
 

Author Comment

by:gammbro
ID: 6477365
OK - that works.

Now, can I refer to the Word Properties dialog box without opening the document in by broswer control, or does the document have to be open?
0
 
LVL 12

Expert Comment

by:roverm
ID: 6478608
No, you cannot access the 'document' properties without a document.
So you still need to open it. If you don't want to show it, just set the oWord.Visible property to false.

D'Mzzl!
RoverM
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:gammbro
ID: 6479777
When I try to run, I get an error on the GetObject function:

Runtime Error '432'

File name or class name not found during Automation operation.

The file exists and I have the correct path specified to the file.
0
 
LVL 12

Expert Comment

by:roverm
ID: 6483570
gammbro:
Where do you get the error (trace through the code ?) ?

0
 

Author Comment

by:gammbro
ID: 6483583
Actually, I got it to work.  I was intializing my variable incorrectly.

However, I have another question related to this.  I am looking to secure my Word documents by placing a password on them.

How can I go about this through vb code?
0
 
LVL 12

Expert Comment

by:roverm
ID: 6483781
This example will allow you to set a password:

    With oWord.ActiveDocument
        .ReadOnlyRecommended = False
        .Password = "myopenpassword"
        .WritePassword = "myeditpassword"
    End With

To remove the password from the document, just set the password to an empty string : "".

After changing it:
oWord.ActiveDocument.Saved = False
oWord.ActiveDocument.Save

You have to do this because else Word 'thinks' that nothing did change, and will NOT update the password.

D'Mzzl!
RoverM
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7207742
Hi gammbro@devx,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept roverm's comment(s) as an answer.

gammbro@devx, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7241087
Per recommendation, force-accepted.

Netminder
CS Moderator
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question