Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Setting Word Document Properties

Does anyone know how to write to the builtin and custom document properties in a Word document?

What I want to do is use VB to insert bits from a database into a Word template with preset fields. I don't want to just stick it in as standard text because then it's hard to read out again. I would use document variables, but the Word 97 I've got crashes when you update a document variable field located in a text box. Also the user can't change variables from within Word, but they can change properties. I could use bookmarks, but then I would have the problem of where to put the original text that the bookmarked areas draw their contents from.

This seems an obvious thing to want to do so I would have thought that it is possible, but I just can't get it to work.


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Setting Properties On A Word/excel Document
I am looking to see if there is anyway setting properties on a document. Ie Summary of the document, Department etc>>???

Word Document Properties

I 'm using VB6.0 /SP5
Word 97 on Win2k

I need to insert a custom document property in a word document.

For this I 've used the following code

WordApp.ActiveDocument.CustomDocumentProperties("Date completed") = Format(Date, "MMM-dd")

But I got the following error;

Runtime Error : 5
Invalid Procedure call or argument.

I 've used the following code instead of CustomDocumentProperties

WordApp.ActiveDocument.BuiltinDocumentProperties("Category")= Format(Date, "MMM-dd")

and it 's worked.

Please help!

Getting And Setting MS Word Custom Properties
I inherited a VB6 project that reeads Word custom properties like so:

CODEDim oProp As Object
Dim strHoldItem As String

   If mwrdDoc Is Nothing Then
      MsgBox ("A Microsoft Word document must be open before modifying the demographics")
      Exit Sub
   End If
   On Error GoTo NoDemographicsError
   Set oProp = mwrdDoc.CustomDocumentProperties("DictatorName")
   With oProp
       frmDemos.strDictatorName = .Value
   End With
   Set oProp = mwrdDoc.CustomDocumentProperties("DictatorID")
   With oProp
      frmDemos.strDictatorID = .Value
   End With
   Set oProp = mwrdDoc.CustomDocumentProperties("DocType")
   With oProp
       frmDemos.strDocType = .Value
   End With
   Set oProp = mwrdDoc.CustomDocumentProperties("PatientName")
   With oProp
       frmDemos.strPatient = .Value
   End With
   Set oProp = mwrdDoc.CustomDocumentProperties("DDJobNumber")
   With oProp
      frmDemos.strJobID = .Value
   End With
etc on for a long time

Change Word Document Properties
I did a search and there are lots of threads about printing in landscape mode from VB. What I want to do is write a Word Document such that when someone opens the Word Doc it appears in landscape mode. Let me explain what I am doing:

I am generating a report from a call to a SQL table. I cycle through the rows returned and write out an HTML table to "Report.doc" then when I go open the document it converts it to an HTML doc and displays the data. That is fine, but the file is in not in landscape mode, so the longer lines get wrapped up quite a bit within the table.

Is this a good way to generate the report? And if so, is there some setting I can put into the file to make it landscape mode when the user opens the report with Word? Is there a better way to format the output from the SQL call into a Word Document? As far as my program is concerned the file I am writing to is a pain text file, I never use the Word plug-in for this at all.


Accessing Properties Of A Word Document
Please, let me know how to access a Word Document's (.doc files) properties such as it's name, type,Date of creation and other statistical details in VB (using VBA) ?

Setting Text Properties In Word Table

i need to set some text to bold inside a cell of a word table
i'm using vb6.

attached is the sample code.

        Set oTable = oDoc.Tables.Add(oDoc.Bookmarks("endofdoc").Range, 5, 2)
        oTable.Range.ParagraphFormat.SpaceAfter = 6
        oTable.Borders.Enable = False
        oTable.Cell(i%, 2).Range.Text = "Text1. Text2"
        oTable.Cell(i%, 2).Range.Font.Underline = False

in the text property of the cell, i need to set "Text1" to bold,
and leave "Text2" as is, with regular font.

any idea how to do this? any help would be greatly appreciated.

Accessing A Word Document's Custom Properties
Hi everyone,

I am trying to write a small piece of code in VB or VBA that changes the custom properties of a Word File. I've tried looking in MSDN and stuff but can't find anything that can help.

Any direction would be much appreciated.

Thanks in advance.

Retrieve File Properties Of Word Document

Is their away in Visual Basic to retrieve the file properties of a word document like Create Date, Modify Date, title,author, publication, key words, etc.
Early help appreciated.


Setting Fonts Within A Vb/Word Document
I have a Access program that automates mailing labels in MS Word. The user will select an item from a list. Once the item is selected, Word is opened to print several pages of one item. My question: How can you set the mailing labels to be a certain font size without having to go into format font everytime? The label is already set up but we would like to code this format. Any suggestions? Thanks.

How To Read/Change Properties Of MS Word Document Using Visual Basic?
Does anyone know how to read/change the properties of MS Word document (eg. Title, Subject, Company, etc) using Visual Basic?

How To Read/Change Properties Of MS Word Document Using Visual Basic?
Does anyone know how to read/change the properties of MS Word document (eg. Title, Subject, Company, etc) using Visual Basic?

Changing &"Properties&" Of A Word Document
How do i change Properties of my word document by using VBA. I've already tried to record it as a marco, but the changes of properties don't show up in the code after recording.
To be more specific, i'd like "Date completed" to be changed to the current date automatically.

Free your mind and seek the truth.

-VolodyA! V Anarhist

Opening Word Document From Excel When The Word Document Is Read Only
I'm trying to open a Word document from Excel and have hit a snag. The file I'm trying to access is Read-only and the code stops when the "This file is read-only..." prompt displays. How do I get past this? Here's the code that I have so far (thanks to some help from this forum):

Sub OpenAndPrint()
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Dim stPathName As String

stPathName = Range("B4").Hyperlinks(1).Address

If Dir(stPathName) <> "" Then
Set wdApp = New Word.Application
wdApp.Visible = True
wdApp.DisplayAlerts = wdAlertsNone 'Tried to turn off the prompt, but it didn't work.
Set wdDoc = wdApp.Documents.Open(stPathName) 'Code stops here and waits for the user to respond to the prompt.
Set wdDoc = Nothing
Set wdApp = Nothing
MsgBox "The file does not exist!", vbInformation
End If

End Sub

MS Word 2000: Closing Forms In A Document From Another Document With Code
I have a project, in which I use a global template to manipulate different other templates. In those templates there are Userforms built in to gather information to use in a MailMerge. The problem I'm having is that I want only to hide the forms in the templates themselves, and close them in the global template when the whole application is closed. The trouble is that I can't find a way to access the open forms from the global template. Can anybody help me?

Setting Properties!!

I am trying to automatically set the CC or BCC fields in Outlook Express!!

Is there any way to do that ?


Setting Properties
Hi all.

I've got a concern: I need to set a Label Caption property of a form before the form is shown. So I set it like this:

FormCoord.LabelHidden = "whatever"
FormCoord.Show 1

And yes, it works. But does it work by chance? I mean FormCoord in not loaded yet, and so FormCoord.LabelHidden shouldn't exist at the point of setting its value. Should I leave it this way? Or is it a weird behavior of VB6? Can someone explain me the mystery?


Setting Properties
I am trying to set the property of an ActiveX control I made in html/vbscript.

Here is the ActiveX Control's code:

Private MyJobKey As Variant

Public Property Let JobKey(ByVal NewValue As Variant)
MyJobKey = NewValue
End Property

Public Property Get JobKey() As Variant
JobKey = MyJobKey
End Property

Private Sub Command1_Click()
MsgBox Me.JobKey
End Sub

Here is the code for the vbscript:


<script language=vbscript>
MyControl.JobKey = 1

So the script should have set the MyControl's JobKey to 1, but when I click on Command1 the message box doesn't display 1. Any ideas?


Setting Properties With AIP
I was wondering how would I be able to to set the background color and forecolor of a textbox using API calls? Thanks.

Setting Properties
If I have a method like this

Public Sub Temp(ByVal Val As String)
oSomething.Val = Val
End Sub

Can I call that like so
oTest.Temp = "Test"
from another component or asp page?
Or does it have to be a property?

Document Properties

Just a question in office document properties.
If I look in the document properties of, for example, a excel file,
the creation date seems to change if I change the time zone settings of my PC.

For example my current time zone is PST time and the creation date is 1/1/2004 2 PM then I change the time zone of my PC to EST, the creation date of the excel file changes to 1/1/2004 5 PM.

But this does not occur to all files with creation date property.What I mean is that some other files with creation date does not change even if I change the time zone settings of my PC.

Is this true to all type of office files of just in excel only?

I test some word documents but the creation date does not change. Powerpoint I think has the same behavior with excel right?


Document Properties
Ok, I'm really starting to remember why I left VB/VBA 7 years ago. Is there nothing intuitive in VBA?

Anyway... how does one set document properties like Title, Comment, etc? Also how to set custom document properties?

I try ActiveDocument.BuiltInDocumentProperties(whatever), but this doesn't work. I guess that method is suppose to return a DocumentProperties collection, but I'll be * * * *ed if I can even find such an object to create.

It doesn't seem it returns an object at all, but acts more like a read-only value. I can't call any methods on




so how is it it returns an object? Or does it?



Document Properties - Where?
Does anybody knows where the document properties are stored?
I cant find if they are stored within the indexing database or within the file itself or somewhere else.

I use the dsofile.dll to set and read custom properties on whatever files (not only msoffice documents).

I wonder:
1/ if they will follow the file if it moves from a computer to another?
2/ if the file is stored on a server, will all the computers on the network be able to see the properties?

Thanks for your help

Document Properties
Is it possible to retrieve the following information from the summary tab of a Microsoft Word Document properties page?


Document Properties Help
Hi All!
I need to access a document's properties thru VB 6.0. Will be upgrading to .net, but for now I need 6.0 help. I found info on DocumentProperties, but I don't know where the following goes.

Private Declare Function DocumentProperties Lib "winspool.drv" (ByVal _
hPrinter As Long) As Long

I've put it at the top of my form code and the module where it would be used and still Dim cp As DocumentProperties

causes a runtime error as "User-define type not defined"

Thanks for any help you can give me!

Setting Startup Properties In VBA
Hey all, i'm trying to program my users to have different types of access depending on their user name. I've been trying to implement startup codes that will disable certain things within VBA. Attached is what i have so far. However, i find that, even with everything disabled (im using the special key "F11" to test) i'm still able to access the "disabled" items.

Edit: k, i kinda got it working now. but now what happens is the affects take place the next time i open it =S is there any way to ensure they affect the database immediately?

Setting The SeriesCollection Properties
I am creating a number of charts within a workbook (programmatically).
When setting the range of the source data, I use the following code:


With Workbooks("Main Menu.xls").Worksheets("Charts").ChartObjects("Chart2").Chart
.SeriesCollection(1).XValues = "=Cal_Rev!R51C5:R51C16"
.SeriesCollection(1).Values = "=Cal_Rev!R52C5:R52C16"
.SeriesCollection(1).Name = "=Cal_Rev!R52C4"
.SeriesCollection(2).XValues = "=Cal_Rev!R51C5:R51C16"
.SeriesCollection(2).Values = "=Cal_Rev!R53C5:R53C16"
.SeriesCollection(2).Name = "=Cal_Rev!R53C4"
.ChartTitle.Text = "Revenue"
End With

I was wondering if it was possible to set the SeriesCollection properties using A1Formula rather than R1C1 (this should include the 'XValues' and 'Name' components).

Any help would be greatly appreciated.


VBA - Setting Application Properties
I am looking for a way to use VBA to set Excel 2002 Application properties using property names and values stored in variables. I have saved Excel settings to the registry using the SaveSetting statement. As an example, the named arguments would be Key:="Application.Cursor" and Setting:=Application.Cursor. I can retrieve the Key and Setting values using the GetAllSettings function. Is there a way to set the property using the literal string value (in this case "Application.Cursor") returned in the GetAllSettings array? I suppose I could set up a Case statement and match each Key value in the array but it seems like there ought to be a way to use the literal array value to reference the property. Thanks much in advance.

Setting Control Properties
Can anyone give me any adv ice on the best way of setting control properties. I.e. before run time in the ide or on the for load event. For example say i have 10 textboxes which all have to enabled or locked or something when the program first loads but they will change at somepoint during the program. Does that make sense?

So would you hardcode it into the form load event or just set them in the ide?

Un Setting Read Only Properties
Dear All,

I need to set "read/write" properties of a folder in Windows XP. However whenever I set this, imediately afterwards it resets itself to "read only". I have tried setting its parent folder to "read/write" and ensured that all sub folders and files are also "read/write". But once again on checking the folder properties they are reset to "read only". NB I am logged in as administrator,

Does anyone have any suggestions?

Cheers Gwyn

Setting Mouse Properties
I have a microsoft mouse with a scroll button. Is it possible to let that button activate the data control so as to scorll through a database on a form?

Setting New Printer Properties

I have actually the settings of about 300 printers to install, and I was wondering if anyone knows a(some) function(s) to set a new printer with all the properties attach to it(PaperBin, PaperSize, drivername, etc.).

API Lib "winspool.drv" ?


Setting Properties Of Db Fields
I have a simple, probably obvious, question. When creating fields in a mdb, how are certain properties, such as format set? For example, a field (fldCost) is created, dbSingle, 8 char long. How can i make that to be percent? Thanks.

Setting Flexgrid Properties
How do you set the format for each column in a FlexGrid?

Also, does anyone know how to set the Font for the headings programmatically?

Setting DataGrid Properties
I am working on an application that has a Data Grid which is populated from a table set in code using an SQL statement.

I can get the grid populated but can't figure out how to set other properties, such as field width and format. If I use the ADO controll it can be done but not if I set the database in code.

Any suggestions?

Setting Display Properties Thru API
I know that it is probably bad to set display settings thru code and have read the posts of the senior members. But, i can assure everyone that in the circumstances that i am in , i require to do so.

I would like to know how can i set

Display properties -> Appearance -> Item (Menu) Fontname (Tahoma) Fontsize (10) Bold (True) (or any set of values of my choice)

Thanks in advance.

Setting ActiveX Properties
I'm a newcomer to using the API but it would appear to me that it may be possible to set a property of an ActiveX component embedded in an application from another application. If it is I could do with some hints. The situation I have is as follows.

The activeX component is MapX (from MapInfo) which adds a map to a form, two of the properties are: Map1.CenterX and Map1.CenterY which when set recenter the map object. I want to be able to set these properties from another application (basically a database front-end containing X, Y pairs), is this possible?

Thanks in anticipation of your help


Setting ActiveX Properties
im coding a button control for a program of mine, and i was wondering, i wanted to make a property on it so when i click the button, it changes color to what i set in the property. can anyone make an example of this?

VB Add-In, Setting Font Properties
Greetings all,

I was wondering if anyone was familiar with how to set font properties through VB's add-in or through the VBE object.

I can get the properties from the control by:


But when I try to assign it's value, I get:

Object doesn't support this property or method


Setting Printer Properties
I use code to change printer properties
ie. Printer.Orientation =vbPRORLandscape
Printer.PaperSize =vbPRPSA4

but it doesn work.

So how to change printer properties ?

Setting Datatype Properties
I use some number datatypes such as zip, phone etc. while adding or updating through a form, i want the form to accept null values for them.
at the same time while displaying data in the form i want it to read null values. what is the best way to set properties for that ?
Vb 6, Ms-access 2000


Setting Control Properties (*.ocx)
How do i set the properties that i make in an ocx. I went to tools and added them yes. then i tried various ways of setting them, but the keep going back to what i set them as and you can not change them. Also i am having a lot of trouble making a background (you know the menu where you select it) if you can help, thanks a bunch. i am gonna try and find some more demos.

: )

Doubt For Setting Properties... Help Me
     I am Suresh. Now I am developing a VB6 project. I want to set a property in Runtime and the same property stored in Permanent.

I am used the following code
VBCOLOR=VBblue or sele3cted color

It's working that time only. Next time I start the project but it not display in blue. default color will be displayed.

I want to set the property in runtime. I want the same color for all time.

Please Help me...

Setting The Properties Of A Textbox
Dear Expert,
I have set the DataFormat property of the textbox to Number with 2 decimal places in design time.
However when I run my application and display a computed value in the textbox, the number of decimal places is more than 2.
Any help.

Setting Control Properties...
Ok, I have a text file and it looks something like this:

Caption=Item Name:


Now, what I would like my program to do is read in this text file, create the controls, and set their properties. I don't have any trouble with the first two, but I was wondering if there is a way to set properties by doing something like


strProperty = "Left=2760"
lblLabel. & strProperty

instead of


If Mid(strProperty, 1, InStr(1, strProperty, "=", vbTextCompare) - 1) = "Left" Then
ElseIf Mid(strProperty, 1, InStr(1, strProperty, "=", vbTextCompare) - 1) = "Top" Then
End If

Any ideas? =)

Setting Font Properties
I have several Labels on a form,

A want to make a function that will set properties
(bold,italic, font name etc) of the label's font.

The problem is that I don't konw how to pass the pointer? or what of the object's font structure.
Any ideas?
Thank you in advance

Using DSO OLE Document Properties Reader 2.0
I can use DSO OLE Document Properties Reader 2.0 to view properties of files on a NTFS partition such as word documents, jpegs, etc. For example, with a Word 2000 document I can view the Title, Author, Comments, etc under the File Properties Tab.

How Can I change these on a file that already exists?

I am not creating the file, just tagging it with useful info.

I can create my own custom tag, such as Address: and assign a value to it, but the custom properties do not show up under file properties in Explorer. I really would like to modify the Title, Author, Comments, etc Properties.

please help...

VB Code:
'*********************************************************************' FileProp.frm'' VB6 Sample code for reading file properties using DSOFILE 2.0''  Copyright (c)1999-2000 Microsoft Corporation, All Rights Reserved'  Microsoft Product Support Services, Developer Support''  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF'  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED'  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR'  A PARTICULAR PURPOSE.''*********************************************************************Option Explicit '*********************************************************************' FileProp Form Member Variables'*********************************************************************' Uses reference to "DSO OLE Document Properties Reader 2.0"Private m_oDocumentProps As DSOFile.OleDocumentProperties '*********************************************************************' Form_Load  -- Creates new instance of the component. Failure here'   will result in termination of the application. You need to register'   the DLL before building and running this sample!!'*********************************************************************Private Sub Form_Load()  ' Create an instance of the DSOFile Object...   Set m_oDocumentProps = New DSOFile.OleDocumentProperties       ' Fill in the default items for the DataType list...   lstCustType.AddItem "String"   lstCustType.AddItem "Long"   lstCustType.AddItem "Double"   lstCustType.AddItem "Boolean"   lstCustType.AddItem "Date"  ' Show the form...   Me.Show       ' Pick a file and open the properties for it,   If Not OpenDocumentProperties Then      End ' If user cancels, we exit...   End If   End Sub '*********************************************************************' Form_Unload  -- Closes the dialog and prompts user to save (if dirty).'*********************************************************************  

Changing The Properties Of A PDF Document With VBA
Does anyone know of any sources of info for coding for V4??

Thanks for your help....


WebBrowser Document Properties

I'm looking for information about WebBrowser.document properties (such as .documentElement, .All.Item().name, etc).
Has anyone has a link ?


Unvealing The Properties Of IE.Document
Dim objIE as ShDocVw.InternetExplorer


Well, the properties and functions of IE.Document is hidden.
May I know how I unveal all these hidden stuffs?
I only know IE.Document has the Title property

Copyright 2005-08, All rights reserved