Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2004

Tip: Looking for answers? Try searching our database.

Arrghhhhhhhh

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
OHM \( Terry Burns \) - 23 Dec 2004 18:02 GMT
Sorry, this is a second post, but now its at the right level

Can someone tell me where to set the following in vb code please

When you open up the document properties. There is a tab called contents in
a blank document the word Title appears, and this can have entries below it.

What does this tab represent
How to access the contents programatically

TIA

Signature

OHM ( Terry Burns )   * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
    ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--

Peter - 23 Dec 2004 18:45 GMT
Try this:

Dim prop As DocumentProperty
Set prop = ActiveDocument.BuiltInDocumentProperties("Title")
prop.Value = "My new Title"

You can also cut out the dim and set statements and simply do:
ActiveDocument.BuiltInDocumentProperties("Title").Value = "My new title"

The above worked for me in Word 2002.

hth,

-Peter

"OHM ( Terry Burns )" <me@mine.com> wrote in message news:%23kVjqkR6EHA.3336@TK2MSFTNGP11.phx.gbl...
> Sorry, this is a second post, but now its at the right level
>
[quoted text clipped - 7 lines]
>
> TIA
OHM \( Terry Burns \) - 23 Dec 2004 19:52 GMT
Thanks, but I was doing the equivelent of this anyway. However, in a strange
quirk of fate I stumbled on a solution. It would appear that if you set the
value of a property, ( at least for this particular one ), that it does not
initialise properly, leaving out the property like so works fine.

ActiveDocument.BuiltInDocumentProperties("Title") = "New Title"

Thanks for trying to help anyway, if you know why this is I would be
interested to find the cause

Signature

OHM ( Terry Burns )   * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
    ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--

Try this:

Dim prop As DocumentProperty
Set prop = ActiveDocument.BuiltInDocumentProperties("Title")
prop.Value = "My new Title"

You can also cut out the dim and set statements and simply do:
ActiveDocument.BuiltInDocumentProperties("Title").Value = "My new title"

The above worked for me in Word 2002.

hth,

-Peter

> Sorry, this is a second post, but now its at the right level
>
[quoted text clipped - 9 lines]
>
> TIA
OHM \( Terry Burns \) - 23 Dec 2004 20:05 GMT
Forget that, it seems to be doing it again, is there some caching issues I
should know about ?

Signature

OHM ( Terry Burns )   * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
    ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--

> Thanks, but I was doing the equivelent of this anyway. However, in a
> strange quirk of fate I stumbled on a solution. It would appear that if
[quoted text clipped - 35 lines]
>>
>> TIA
Peter - 23 Dec 2004 20:10 GMT
Hmm.... I found that both methods work for me, BUT, I did find what seems to me to be a bug in Word:

When the Title (probably applies to other properties, too) is set, then the document must be saved for the change to apply.  Changing a Document Property apparently does not set the document state to dirty, so it is not automatically saved upon closing.

So, using .Value will work, as will your method, you just have to explicitly save the document.

hth,

-Peter

"OHM ( Terry Burns )" <me@mine.com> wrote in message news:uLoHNiS6EHA.2876@TK2MSFTNGP12.phx.gbl...
> Thanks, but I was doing the equivelent of this anyway. However, in a strange
> quirk of fate I stumbled on a solution. It would appear that if you set the
[quoted text clipped - 34 lines]
> >
> > TIA
OHM \( Terry Burns \) - 23 Dec 2004 20:19 GMT
Actually, the problem is something else completely. I found that my template
somehow had gotten a value in the title field, and if this happen, setting
the Title Field Programatically does not affect the documents content value.

I cleared this and re-ran it, it would seem to work fine.  However, from an
academic point of view I would like to know

1.) Why this happens
2.) How to change what appears in the document content tab in the properties
dialog.

Hope you can help, I hate things I dont understand !

Signature

OHM ( Terry Burns )   * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
    ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--

Hmm.... I found that both methods work for me, BUT, I did find what seems to
me to be a bug in Word:

When the Title (probably applies to other properties, too) is set, then the
document must be saved for the change to apply.  Changing a Document
Property apparently does not set the document state to dirty, so it is not
automatically saved upon closing.

So, using .Value will work, as will your method, you just have to explicitly
save the document.

hth,

-Peter

> Thanks, but I was doing the equivelent of this anyway. However, in a
> strange
[quoted text clipped - 37 lines]
> >
> > TIA
Peter - 24 Dec 2004 00:44 GMT
The problem is not the title of the template, it's just that you need to explicitly save the document after changing the title.
Simply invoking ActiveDocument.Save isn't enough, since changing the title doesn't make the document "dirty" so .Save does nothing.  Before invoking ActiveDocument.Save, invoke ActiveDocument.Saved = False in order to force the document to save.  Why changing the title doesn't "dirty" the document beats me.

I put the following sub in the ThisDocument module of a template, then created a document based on it.  It changed the title of the document every time (after the initial creation, naturally).

Private Sub Document_Open()
   Dim sTitle As String
   
   If ActiveDocument.Type = wdTypeDocument Then

       sTitle = ActiveDocument.BuiltInDocumentProperties("Title").Value
       
       MsgBox "Old Title: " & sTitle
       
       On Error Resume Next
       sTitle = CStr(CInt(sTitle) + 1)
       If Err Then
           sTitle = "0"
       End If
       On Error GoTo 0
       
       MsgBox "New Title: " & sTitle
       
       ActiveDocument.BuiltInDocumentProperties("Title").Value = sTitle
       ActiveDocument.Saved = False
       ActiveDocument.Save
   End If
End Sub

hth,

-Peter

"OHM ( Terry Burns )" <me@mine.com> wrote in message news:eAdhexS6EHA.824@TK2MSFTNGP11.phx.gbl...
> Actually, the problem is something else completely. I found that my template
> somehow had gotten a value in the title field, and if this happen, setting
[quoted text clipped - 65 lines]
> > >
> > > TIA
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.