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 / February 2006

Tip: Looking for answers? Try searching our database.

Update Subject document property from Userform Input

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
OZO - 21 Feb 2006 00:16 GMT
I have a userform that prompts the user to insert a subject for their
memo/letter/fax into textbox4 for example. I would like the subject response
to update the Subject of the document properties.
I am using  the following code

wdPropertySubject = TextBox4.Text

but get an error message advising the field is a constant when running the
code.
How do I work around this please or am I using the incorrect code for this
action to work

Thanking you for your help in advance
Signature

Odge
IT Training and Support Consultant
PC Training Online Aust

Jay Freedman - 21 Feb 2006 02:34 GMT
>I have a userform that prompts the user to insert a subject for their
>memo/letter/fax into textbox4 for example. I would like the subject response
[quoted text clipped - 9 lines]
>
>Thanking you for your help in advance

The error message is correct because wdPropertySubject *is* a
constant. You have to use the constant this way:

ActiveDocument.BuiltInDocumentProperties(wdPropertySubject) =  _
 TextBox4.Text

In general, anything you find in VBA that starts with "wd", "vb", or
"mso" is a constant. It may be an index into a collection, like the
example above, or it may be a valid value of a property. You can find
out what they are by pressing F2 while in the VBA editor to open the
Object Browser, and typing all or part of the name into the Search
box.

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
OZO - 21 Feb 2006 03:39 GMT
Thanks worked perfect

I am trying to add the subject field at a bookmark in the document so that
Subject is taken form TextBox4's value.

I am using the following code at the book mark

Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
'    "Subject =TextBox4.Text \ * Upper, PreserveFormatting:=True"

From the coding you can see that the subject always reads =TextBox4.Text
literally.

What should I replace in the "subject line to take the value of TextBox 4?

Thanks in advance
Signature

Odge
IT Training and Support Consultant
PC Training Online Aust

> >I have a userform that prompts the user to insert a subject for their
> >memo/letter/fax into textbox4 for example. I would like the subject response
[quoted text clipped - 29 lines]
> Email cannot be acknowledged; please post all follow-ups to the
> newsgroup so all may benefit.
Jonathan West - 21 Feb 2006 12:31 GMT
Hi Odge

If you want the current subject to appear, all you need to is insert a field
of type wdFieldSubject. From where the macro gets the text to put into the
Subject property doesn't matter in the least to the field.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

> Thanks worked perfect
>
[quoted text clipped - 49 lines]
>> Email cannot be acknowledged; please post all follow-ups to the
>> newsgroup so all may benefit.
Charles Kenyon - 22 Feb 2006 15:45 GMT
Consider using (and updating) a field in your document rather than a
bookmark. Since you are already changing the document property, you could
use a DocProperty field to show it in your document. { DocProperty Subject }
Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

> Thanks worked perfect
>
[quoted text clipped - 49 lines]
>> Email cannot be acknowledged; please post all follow-ups to the
>> newsgroup so all may benefit.
 
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.