msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

My 1st Word doc by VB6 automatn Try set margins and fonts

 
Post new topic   Reply to topic    msvisual.com Forum Index -> OLE Automation
Author Message
Lamont



Joined: 04 Oct 2007
Posts: 21

PostPosted: Sun May 27, 2007 4:45 am    Post subject: My 1st Word doc by VB6 automatn Try set margins and fonts Reply with quote

I found some code to create a Word doc from VB6 and that works OK.
Could not set DocumentProperty in DocumentProperties collection, so created
a Macro in Word and copied the macro into my VB6 program. That method
helps a lot in Excel. But nothing of the Word macro works in VB6.
???????
Private oWord As Object
Private oDoc As Object
Private Sub Form_Load()
Set oWord = CreateObject("word.application")
Set oDoc = oWord.documents.Add()
oDoc.Activate
'I can debug print the oDoc name - it is Document1 ...
With oDoc.Styles(wdStyleNormal).Font 'Fails
If .NameFarEast = .NameAscii Then
.NameAscii = ""
End If
.NameFarEast = ""
End With
With oDoc.PageSetup
' TopMargin = oDoc.InchesToPoints(0.4)
'above failed. obj d/not support prop or meth
Am I the only one on the planet for whom MS object model don't seem to work?
Thank you for kind help.

Archived from group: microsoft>public>vb>ole>automation
Back to top
View user's profile Send private message
Lamont



Joined: 04 Oct 2007
Posts: 21

PostPosted: Sun May 27, 2007 2:00 pm    Post subject: Margin & font set appears to work but font changes dont appe Reply with quote

I thought the Office 10 libraries were sufficient, but then I found the Word
libraries in the tiny scroll box. Now the code runs, and the margins set OK.
When the statemment objdoc.select execcutes, the text becomes highlighted in
the document. Then, the statements that set the font to Courier New and 8
pitch appear to work and I can debug.print the values after setting. But,
the changes do not appear in the document which remains with New Times Roman
and 12 pitch???? Mystery, mystery.
--

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    msvisual.com Forum Index -> OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group