473,320 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Word style problem

Hi,

I try to add/modify some style in Word 2002 and 2003 using VB, but I have
such error :
System.runtime.interopServces.COMException(0x800A1 735) : 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).LineStyl e =
Word.WdLineStyle.wdLineStyleNone
.Borders(Word.WdBorderType.wdBorderTop).LineStyle =
Word.WdLineStyle.wdLineStyleNone
.Borders(Word.WdBorderType.wdBorderBottom).LineSty le =
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()
Nov 21 '05 #1
0 2738

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: provaands | last post by:
Defects of the code below: with Mozilla, Netscape, the word hellooo..... exit outside from the div; with IE 5,5, 6 the word hellooo.... increase the width of the div, even if i have fixed to...
8
by: Jaime Rios | last post by:
Hi, I created a COM AddIn for Word that performs the functions that it needs to, but I needed to add the ability for the toolbar created by the COM AddIn to remember it's last position and...
5
by: STeve | last post by:
Hey guys, I currently have a 100 page word document filled with various "articles". These articles are delimited by the Style of the text (IE. Heading 1 for the various titles) These articles...
2
by: briano | last post by:
Is there a library that allows editing Word documents in the browser that is browser independent? Please forgive this question. Just trying to cover all bases. So far what I see is HTML or RTF...
2
by: Ola K | last post by:
Hi guys, I wrote a script that works *almost* perfectly, and this lack of perfection simply puzzles me. I simply cannot point the whys, so any help on it will be appreciated. I paste it all here,...
1
by: =?Utf-8?B?Y3JhaWc=?= | last post by:
I am trying to insert text into a Word document and then apply a style to the paragraph I just wrote. My problem is that the range stays set to the entire document and I can't figure out how to...
0
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
I am creating a webpage and opening it as a Word document. Problem is that as I create one of the questions, some of the text is not appearing in the document as it should. As I step through it, I...
6
by: Eric Layman | last post by:
Hi, I have fields from textareas. With a click of a button, php is able to grab these fields and by using header(), convert the output to Ms Word doc. But the outcome of the word doc...
0
by: srk | last post by:
hi to all, i need some help , my problem is that i have to generate a word document withe the data from data base and it should be displayed as tables in word and i have to insert some header and...
0
by: krishnagovindaraj | last post by:
Hi, I have to create word document with header and footer..its working in web layout.In Print Layput,the header is displayed two times..Plz give me the solution...its very urgent.. strBody =...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.