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 

WORD automation

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



Joined: 04 Oct 2007
Posts: 1

PostPosted: Tue Sep 13, 2005 7:46 am    Post subject: WORD automation Reply with quote

Hi,

I try to add/modify some style in Word 2002 and 2003 using VB, but I have
such error :
System.runtime.interopServces.COMException(0x800A1735) : Given Items does
not exist.
at word.Styles.get_item(Object& Index)

i don't have any number of code line where is the mistake..
i only know that my code is the following one :

wdApp = New Word.Application
wdDoc = wdApp.Documents.Add
'Word is hidden
wdApp.Visible = False

'Add 2 new styles to document
With wdDoc.Styles("Normal").Font
.Name = "Arial"
.Size = 10
.Bold = 0
.Italic = 0
.Underline = WdUnderline.wdUnderlineNone
.UnderlineColor = WdColor.wdColorAutomatic
.StrikeThrough = 0
.DoubleStrikeThrough = 0
.Outline = 0
.Emboss = 0
.Shadow = 0
.Hidden = 0
.SmallCaps = 0
.AllCaps = 0
.Color = WdColor.wdColorAutomatic
.Engrave = 0
.Superscript = 0
.Subscript = 0
.Scaling = 100
.Kerning = 0
.Animation = Word.WdAnimation.wdAnimationNone
End With

wdDoc.Styles.Add(Name:="DS SLA1",
Type:=Word.WdStyleType.wdStyleTypeParagraph)
wdDoc.Styles("DS SLA1").AutomaticallyUpdate = False
With wdDoc.Styles("DS SLA1").Font
.Name = "Arial"
.Size = 12
.Bold = 1
.Italic = 0
.Underline = WdUnderline.wdUnderlineNone
.UnderlineColor = WdColor.wdColorAutomatic
.StrikeThrough = 0
.DoubleStrikeThrough = 0
.Outline = 0
.Emboss = 0
.Shadow = 0
.Hidden = 0
.SmallCaps = 0
.AllCaps = 0
.Color = WdColor.wdColorAutomatic
.Engrave = 0
.Superscript = 0
.Subscript = 0
.Scaling = 100
.Kerning = 0
.Animation = Word.WdAnimation.wdAnimationNone
End With
With wdDoc.Styles("DS SLA1").ParagraphFormat
.LeftIndent = wdApp.CentimetersToPoints(0)
.RightIndent = wdApp.CentimetersToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = 0
.SpaceAfter = 0
.SpaceAfterAuto = 0
.LineSpacingRule = Word.WdLineSpacing.wdLineSpaceSingle
.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft
'.WidowControl = CInt(1)
.KeepWithNext = 0
.KeepTogether = 0
.PageBreakBefore = 0
.NoLineNumber = 0
'.Hyphenation = 1
.FirstLineIndent = wdApp.CentimetersToPoints(0)
.OutlineLevel = Word.WdOutlineLevel.wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
wdDoc.Styles("DS SLA1").NoSpaceBetweenParagraphsOfSameStyle = False
wdDoc.Styles("DS SLA1").ParagraphFormat.TabStops.ClearAll()
With wdDoc.Styles("DS SLA1").ParagraphFormat
With .Shading
.Texture = Word.WdTextureIndex.wdTextureNone
.ForegroundPatternColor = Word.WdColor.wdColorAutomatic
.BackgroundPatternColor = Word.WdColor.wdColorAutomatic
End With
.Borders(Word.WdBorderType.wdBorderLeft).LineStyle =
Word.WdLineStyle.wdLineStyleNone
.Borders(Word.WdBorderType.wdBorderRight).LineStyle =
Word.WdLineStyle.wdLineStyleNone
.Borders(Word.WdBorderType.wdBorderTop).LineStyle =
Word.WdLineStyle.wdLineStyleNone
.Borders(Word.WdBorderType.wdBorderBottom).LineStyle =
Word.WdLineStyle.wdLineStyleNone
With .Borders
.DistanceFromTop = 1
.DistanceFromLeft = 4
.DistanceFromBottom = 1
.DistanceFromRight = 4
.Shadow = False
End With
End With
wdDoc.Styles("DS SLA1").LanguageID = Word.WdLanguageID.wdEnglishUS
wdDoc.Styles("DS SLA1").NoProofing = 0
wdDoc.Styles("DS SLA1").Frame.Delete()

Archived from group: microsoft>public>vb>ole>automation
Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Word Automation Hi, I have this code it works fine in MS Access 2000, I am trying to make it work in VB 6, I am not getting an error, but the variables in the word document "{ADDRESS}" an so on are not being replaced with the data. this is the table data in the table Cod

Need Help with Word Automation from VB6 I need to add a function to an existing VB6 app to print a mailing label on a standard Avery label. I'd like to use the Word mailing labels dialog to do the work. I'm working with Word 2003 SP1. And, I'm an absolute newbie to Word object

automation of Word Using article Q220607 How to automate Word to perform Mail Merge from VB. I am using VB6 to automate Word 2003 Mail Merge. I get the following error: Run Time 5631 Word could not merge the main document with the datasource because data records were empty

Word Automation Dim appWord as Object Set appWord = How am I able to use the following when appWord as an Object and wrdDocument as an Object. I had no problem when appWord as and wrdDocument as Word.Document and Set app

Word Hangs during Automation I am attempting to read a large number of Word Documents through a VB6 application. I am successfully doing this. However, some of the documents are damanaged, some may be password protected, some may be read only ,etc. I think it is the damanged documen
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