Extracting Application Settings (Name, Address, Initials)

I

Ian Bayly

In VB6 I need to extract the Username, Initials and Address info held in
"Tools-Options-User Info".
I can extract UserName but routine fails( Err438 - Object doesn't support
....) when I try Initials or Address.
Tried early and late binding .
Here is code snip:
~~~~~~~~~~~~~~~~~~~~
With objWdDoc
lName_s = Application.UserName
lInits_s = Application.UserInitials
lAddress_s = Application.UserAddress
End With
~~~~~~~~~~~~~~~~~~~~
I realise this is a strictly VB6 question but it will require Word knowledge
to answer.
Appreciate any advice.

Ian B
 
J

Jay Freedman

Hi, Ian,

I can't reproduce your problem, at least with VB6 and Word 2000 on Windows
2000. Here's the early-binding code (set a reference to Microsoft Word 9.0
Object Library), which works perfectly here:

Private Sub Command1_Click()
Dim objWd As Word.Application
Dim objWdDoc As Word.Document
Dim lName_s As String, lInits_s As String, _
lAddress_s As String

Set objWd = New Word.Application
objWd.Visible = True
Set objWdDoc = objWd.Documents.Add

With objWdDoc
lName_s = Application.UserName
lInits_s = Application.UserInitials
lAddress_s = Application.UserAddress
End With

MsgBox lName_s & vbCr & lInits_s & vbCr & lAddress_s
objWdDoc.Close wdDoNotSaveChanges
objWd.Quit
Set objWdDoc = Nothing
Set objWd = Nothing
Unload Me
End Sub
 
T

Tom Winter

Ian Bayly said:
In VB6 I need to extract the Username, Initials and Address info held in
"Tools-Options-User Info".
I can extract UserName but routine fails( Err438 - Object doesn't support
...) when I try Initials or Address.
Tried early and late binding .
Here is code snip:
~~~~~~~~~~~~~~~~~~~~
With objWdDoc
lName_s = Application.UserName
lInits_s = Application.UserInitials
lAddress_s = Application.UserAddress
End With
~~~~~~~~~~~~~~~~~~~~
I realise this is a strictly VB6 question but it will require Word knowledge
to answer.
Appreciate any advice.

Ian B

As an aside, there is no reason for you to be using "With objWdDoc" in this
code. You are not referencing it at all.

-Tom
 
I

Ian Bayly

Tks for advice Tom

Because the options are not available manually from Tools-Options-User Info
unless a document is open, I opened a document to see if that was my problem
when running the code
..
Ian B
 
I

Ian Bayly

Thanks for your help Jay.

Your code runs fine on my System.
I think I trashed the code I was using for testing, but I'll see if I can
find it so to see what is different between your sample and my attempts.

Again many thanks

Ian B
 
Top