473,789 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(0x 800A1735) : 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.Applicatio n
wdDoc = wdApp.Documents .Add
'Word is hidden
wdApp.Visible = False

'Add 2 new styles to document
With wdDoc.Styles("N ormal").Font
.Name = "Arial"
.Size = 10
.Bold = 0
.Italic = 0
.Underline = WdUnderline.wdU nderlineNone
.UnderlineColor = WdColor.wdColor Automatic
.StrikeThrough = 0
.DoubleStrikeTh rough = 0
.Outline = 0
.Emboss = 0
.Shadow = 0
.Hidden = 0
.SmallCaps = 0
.AllCaps = 0
.Color = WdColor.wdColor Automatic
.Engrave = 0
.Superscript = 0
.Subscript = 0
.Scaling = 100
.Kerning = 0
.Animation = Word.WdAnimatio n.wdAnimationNo ne
End With

wdDoc.Styles.Ad d(Name:="DS SLA1",
Type:=Word.WdSt yleType.wdStyle TypeParagraph)
wdDoc.Styles("D S SLA1").Automati callyUpdate = False
With wdDoc.Styles("D S SLA1").Font
.Name = "Arial"
.Size = 12
.Bold = 1
.Italic = 0
.Underline = WdUnderline.wdU nderlineNone
.UnderlineColor = WdColor.wdColor Automatic
.StrikeThrough = 0
.DoubleStrikeTh rough = 0
.Outline = 0
.Emboss = 0
.Shadow = 0
.Hidden = 0
.SmallCaps = 0
.AllCaps = 0
.Color = WdColor.wdColor Automatic
.Engrave = 0
.Superscript = 0
.Subscript = 0
.Scaling = 100
.Kerning = 0
.Animation = Word.WdAnimatio n.wdAnimationNo ne
End With
With wdDoc.Styles("D S SLA1").Paragrap hFormat
.LeftIndent = wdApp.Centimete rsToPoints(0)
.RightIndent = wdApp.Centimete rsToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAut o = 0
.SpaceAfter = 0
.SpaceAfterAuto = 0
.LineSpacingRul e = Word.WdLineSpac ing.wdLineSpace Single
.Alignment = Word.WdParagrap hAlignment.wdAl ignParagraphLef t
'.WidowControl = CInt(1)
.KeepWithNext = 0
.KeepTogether = 0
.PageBreakBefor e = 0
.NoLineNumber = 0
'.Hyphenation = 1
.FirstLineInden t = wdApp.Centimete rsToPoints(0)
.OutlineLevel = Word.WdOutlineL evel.wdOutlineL evelBodyText
.CharacterUnitL eftIndent = 0
.CharacterUnitR ightIndent = 0
.CharacterUnitF irstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
wdDoc.Styles("D S SLA1").NoSpaceB etweenParagraph sOfSameStyle = False
wdDoc.Styles("D S SLA1").Paragrap hFormat.TabStop s.ClearAll()
With wdDoc.Styles("D S SLA1").Paragrap hFormat
With .Shading
.Texture = Word.WdTextureI ndex.wdTextureN one
.ForegroundPatt ernColor = Word.WdColor.wd ColorAutomatic
.BackgroundPatt ernColor = Word.WdColor.wd ColorAutomatic
End With
.Borders(Word.W dBorderType.wdB orderLeft).Line Style =
Word.WdLineStyl e.wdLineStyleNo ne
.Borders(Word.W dBorderType.wdB orderRight).Lin eStyle =
Word.WdLineStyl e.wdLineStyleNo ne
.Borders(Word.W dBorderType.wdB orderTop).LineS tyle =
Word.WdLineStyl e.wdLineStyleNo ne
.Borders(Word.W dBorderType.wdB orderBottom).Li neStyle =
Word.WdLineStyl e.wdLineStyleNo ne
With .Borders
.DistanceFromTo p = 1
.DistanceFromLe ft = 4
.DistanceFromBo ttom = 1
.DistanceFromRi ght = 4
.Shadow = False
End With
End With
wdDoc.Styles("D S SLA1").Language ID = Word.WdLanguage ID.wdEnglishUS
wdDoc.Styles("D S SLA1").NoProofi ng = 0
wdDoc.Styles("D S SLA1").Frame.De lete()
Nov 21 '05 #1
0 2775

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

Similar topics

10
2547
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 100px the width; Question: can I make so that word hellooooo..... remains all within to the div? I do not want to use overflow in order to see the text with the sliding bar, but it must to increase the height of the div, so the div can to contain...
8
3036
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 whether it was docked or not. I added the following code to my "OnConnection" function but it fails with an error, "Run-time exception thrown : System.IO.IOException - Bad file name or number." With applicationObject.CommandBars("SampleToolbar")
5
12872
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 will then be converted into HTML and saved. I want to write a parser through vb.net that uses the word object model and was wondering how this could be achieved? The problem i am running into is that i can not test whether the selected text is...
2
2231
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 editing in the browser. Need the ".DOC" standard so no conversion will have to take place when saving or retrieving this to or from the server. TIA -
2
5099
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, the string at the beginning explains what it does: '''A script for MS Word which does the following: 1) Assigns all Hebrew italic characters "Italic" character style. 2) Assigns all Hebrew bold characters "Bold" character style. 2) Assign all...
1
1988
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 reset it to the end of the document so whatever style I apply applies to just the last paragraph I wrote. Right now the style gets applied to the entire document. Here is the class: Imports System.IO Imports System.Runtime.InteropServices Imports...
0
1648
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 can see the text in my string builder variable, but once the page opens as a Word document, that same text is not showing. It seems to only be text that I am displaying as a result of some checkboxes I am trying to write to the page. Can anyone...
6
4644
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 doesn't wrap the text in textarea. the result is one very veyr long string of text which stretch MS word all
0
2543
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 footer in word along with the page number. i got the code for generating tables and it is fine now i am trying for header and footer but i am failing here. i am sending my code , just check it. StringBuilder sbTop = new StringBuilder();
0
2216
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 = "<html xmlns:o='urn:schemas-microsoft-com:office:office' " & _ "xmlns:w='urn:schemas-microsoft-com:office:word'" & _ "xmlns='http://www.w3.org/TR/REC-html40'>" strBody = strBody + "<!-->" & _ "<xml>" & _ "<w:WordDocument>" & _
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9499
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10374
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10124
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8998
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5405
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5540
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2898
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.