Quantcast
Channel: Word for Developers forum
Viewing all 4350 articles
Browse latest View live

remove paragraph formatting

$
0
0

Hi,

I want to remove the paragraph formatting from the current selection. See picture below. The paragraph contains two blue lines. How can I remove them programmatically like the CTRL-Q command at Outlook?

I've tried:

Word.Document d = (Word.Document) mi.GetInspector.WordEditor;
Word.Selection cs = d.Application.Selection;
cs.ClearParagraphAllFormatting();

Jens

blue line


How can I distinguish special characters or signs in Doc through VBA?

$
0
0

How can I distinguish special characters or signs in Doc through VBA?

I have a few large documents written in word 2003 format and now I work on them under word 2007.
Such large documents containing lots of special characters.  I want to change them into Microsoft 3.0 equation form(It is required by the team). I find no way but using function AddOLEObject and  Sendkeys through VBA. Common characters can be added to equation by function Sendkeys, but the return value of Asc() or AscW() for "double arrow", "in" , " not greater than " such special characters or signs, to name but a few are the same ,i.e., 40 And I cannot distinguish them.

I found the link http://msdn.itags.org/word/44333/ may be of use to me, and the title is:
How to read symbols from a DOC documents! (Microsoft Word)
 the original question is
Using function "InsertSymbol", I can insert a symbol into a document. But
how can I read a symbol from a document?
Using "Characters(i).range.text", I can read a char. But when meeting a
symbol, the value of "Characters(i).range.text" is always '('.How can I get the CharacterNumber of the symbol.


And the final answer is :
Hi chenfeng,

Word protects symbols from symbol fonts if you insert them from the "Insert
> Symbol" dialog.

This is done so they aren't changed when you change the font or style. But
it also results in Word reporting AscW( ) = 40 on all of them.

I've posted a macro to "unprotect" them (or to protect them again if you
want) ... just today again in

Newsgroups: microsoft.public.word.vba.customization
Subject: Symbol Characters
Date: Mon, 3 May 2004 11:00:46 -0700
Message-ID: <09f401c43138$8f92f900$7d02280a@msdn.itags.org.phx.gbl>

It isn't archived on Google yet, but tomorrow you should be able to simply
copy the message ID into http://www.google.com/advanced_group_search.

Regards,
Klaus


But the link for the macro in the final answer is missing.

Can anyone with kindness help me? Thaks a lot.

Listview checkbox disappear in the multiple page for listview control version 6.0

$
0
0

Hi All

As the captioned, I encounter one issue for the listivew.

I create one form, and drag the mutiple page in the form, in one tab, i drag the listview to display the data, and also set the listview checkbox property as true.

When i tick the checkbox in the listview, and navigate to the another tab, and then go back to the listview tab.

the strange thing happen, all the checkbox in the listview disappearred.

Is anyone know how to solve this issue?

Thanks in advance.

Microsoft Word Drop Down List

$
0
0

Hi,

I have a name list from master workbook. In microsoft word i want to create a drop down list which refer to the said master workbook, so anyone know how to get it by using VBA code?

How Could I Know How Many Cells be merged in one, C#&&Microsoft.Office.Interop.Word?

$
0
0

Context : In my Word Add in project, i want to reDraw MSWord's table.

Problem: When the merged cells in one row are more than one, I can do nothing to make sure how many cells the one of merged cells contains.

HELP!

Can i disable a button inside a ribbon class from another class under the same namesapce ?

$
0
0
In a word add-in application , can i disable a button inside the ribbon class from another class under the same namespace ?

microsoft word 2010

$
0
0
Good Morning

I have asolutionmadewith VisualStudio2010thatwill insert picturesin MicrosoftWord 2010.I have usedMicrosoftOffice14.0Object Library, as we haveMicrosoftoffice 2010.everythingworks finebut when the company installed lync2013allimplementation walkingwith Worddo not work. withLync 2010there wasno problem.Soto createObject "CreateObject" thereis no problembut itbugsall the time in"visible"and "add"newTemplate. i mean,  when I wanttomake it visibleand open theTemplate.I did someresearchbut without success. Sothe way I'm trying todo this is with"latebinding"exp"Dim oDocas object", "dim  docAppasobject"but difficult when it comes to work with Bookmarks , Sélections ,and page layout.My question is:is  there  anotherway?.Whydoes it workwithLync2010andLync 2013does not work?Issomeonehas alreadyencountered thisproblem ?.- i can not create 2 solutions because i have only word object 14.0 , i mean Microsoft office 2010 but also lync 2013.i hope someone Canhelp me withthisproblem.

Thankyou in advance

Pavel

Add a bullet correctly below the text in the previous line.

$
0
0

Hi All,

I know how to add bullets in a word doc, but I dont know how to set the range.listformat.leftindent property to match this particular reuirement i.e

1.1.1.   some text 

           (add a bullet below s in some)

normal text

(add a bullet below n) 

i.e check where start of the text is , in the previous line add a bullet right below this text dynamically

           



TOC VSTO creating and updating problems

$
0
0

Hey,

i'm tring to create Word document contains: Main Page(image and title), TOC at second page and some Chapters with text next. (each chapter a new page)

I have some problems :

when i add InsertBreak, i cant update TOC becouse Update() cant see toc.

I can create toc at the end of document but how move it at secnd page when document is ready?

Thank you for any advice.

    //First|Main Page
            Word.Paragraph firstPageLogoParagraph = wordDocument.Content.Paragraphs.Add(ref oMissing);
            Word.InlineShape inlineShape = wordDocument.InlineShapes.AddPicture(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Resources\logo.jpg", ref oMissing, ref oMissing, ref oMissing);
            inlineShape.ScaleHeight = (float)300.00;
            inlineShape.ScaleWidth = (float)300.00;
            firstPageLogoParagraph.Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            firstPageLogoParagraph.Range.InsertParagraphAfter();
            //First|Main Page Title
            Word.Paragraph firstPageParagarph = wordDocument.Content.Paragraphs.Add(ref oMissing);
            object firstPageParagraphStyle = Word.WdBuiltinStyle.wdStyleTitle;
            firstPageParagarph.Range.set_Style(ref firstPageParagraphStyle);
            firstPageParagarph.Range.Text = "\nWojskowa Akademia Techniczna" + softEnter + "im. Jarosława Dąbrowskiego" + softEnter + "w Warszawie";
            firstPageParagarph.Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            firstPageParagarph.Range.InsertParagraphAfter();
            firstPageParagarph.Range.InsertBreak();

            //Second Page|TOC Page
            object tocStart = wordApplication.ActiveDocument.Content.End - 1;
            Word.Range tocRange = wordDocument.Range(ref tocStart, ref oMissing);
            tocRange.InsertAfter("Spis treści\r");
            Word.TableOfContents toc = wordDocument.TablesOfContents.Add(tocRange, ref oTrue, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oTrue, ref oTrue, ref oMissing, ref oTrue, ref oMissing, ref oMissing);
            //tocRange.InsertBreak();
            
            //Some paragraph
            //Add Paragraph after TOC
            Word.Paragraph firstParagraph = wordDocument.Content.Paragraphs.Add(ref oMissing);
            firstParagraph.Range.Text = "Rozdział 1";
            object firstParagraphStyle = Word.WdBuiltinStyle.wdStyleHeading1;
            firstParagraph.Range.set_Style(ref firstParagraphStyle);
            firstParagraph.Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft;
            firstParagraph.Range.InsertParagraphAfter();

            //Add Text after Paragraph 1
            Word.Paragraph firstParagraphText = wordDocument.Content.Paragraphs.Add(ref oMissing);
            firstParagraphText.Range.Text = "To jest tekst pod rozdziałem 1. Taki tekst wstawiłem pod tym tekstem.";
            object firstParagraphTextStyle = Word.WdBuiltinStyle.wdStyleNormal;
            firstParagraphText.Range.set_Style(ref firstParagraphTextStyle);
            firstParagraphText.Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphJustify;
            firstParagraphText.Range.InsertParagraphAfter();
            //firstParagraphText.Range.InsertBreak();

            toc.Update();




Excel-file that looks right but it shows a different informations when you print it or convert it to PDF-file

$
0
0

We'd a problem within an Excel-file that looks right in the word-document and in the preview, but it shows a different informations when you print it or convert it to PDF-file. 

{ EMBED Excel.Sheet.8 }

Unit Designation:                                    (Name) NCMM, MDM25S Part Number: CI-number: 
Document Number:-Issue/Revision:10Date: 
Line No.Connector IDPinPin RtnSignal NameSignal TypeEMC TypeLoad/ SourceVoltage [V]Current [mA]Resistance [Ohm]Capacity [pF]Frequency [Hz]Pulse Duration [ms]Remarks  Number of pinsChange in issue
 J1021 V15_NomPower L       10
 J1022 GND          10
 J1023 V3_NomPower L       10
 J1024 V3_NomPower L       10
 J1025 GND          10
 J1026 GND          10
 J1027 V3_NomPower L       10
 J1028 V3_NomPower L       10
 J1029 GND          10
 J10210 V5_NomPower L       10
 J10211 V5_Tm_1AN S       10
 J10212 V3_RouterA_Tm_1AN S       10
 J10213 V3_RouterB_Tm_1AN S       10
 J10214 V15_NomPower L       10
 J10215 GND          10
 J10216 V3_NomPower L       10
 J10217 V3_NomPower L       10
 J10218 GND          10
 J10219 GND          10
 J10220 V3_NomPower L       10
 J10221 V3_NomPower L       10
 J10222 GND          10
 J10223 V5_NomPower L       10
 J10224 GND          10
 J10225 V3_CoPm_Tm_1AN S       10
BoardNCMM
Local Id

I got the file to send if someone can help me !

UndoRecord - Range.InsertXml

$
0
0

Hi,

I'm trying to group Range.InsertXml calls in an Undo scope but they're not grouping.

Is it possible to group Range.InsertXml calls?

I'm able to group Range.InsertBefore, Range.InsertAfter etc calls.

Thanks

var undoRecord = _wordApplication.Application.UndoRecord;
undoRecord.StartCustomRecord("Test");
....
selectedRange.InsertXml("...valid xml...")
....
undoRecord.EndCustomRecord();


VB.net – how do you set a variable to get ActiveDocument name

$
0
0

I have an existing Word session running

A word document is open – DocumentOne

I would like to obtain and set a variable to DocumentOne

A second document is opened – DocumentTwo

I would like to obtain and set a variable to DocumentTwo active Document name

Select and activate DocumentOne

Edit DocumentOne

Select and activate DocumentTwo

Edit DocumentTwo

Select and activate DocumentOne

Do until end…

I have working code in VBA. However vb.net fails, and it maybe due to my declarations.

I’ve searched the net and some examples declare a new instance of Word.  However I’m using the current open Word session/Instance.

This is my working VBA code.

Dim DocOne As Document

Dim DocTwo As Document

Dim strDocOne As String

dim 

Set DocOne = ActiveDocument

x = ActiveDocument.Sections.Count

strDocOne = ActiveDocument.ActiveWindow.Caption

MsgBox (ActiveDocument.ActiveWindow.Caption)

MsgBox (strDocOne)

‘File Open second doc

Set DocTwo = ActiveDocument

Windows(strDocOne).Activate

ActiveDocument.Sections(j).Range.Select

Selection.Copy

Vb.net code Fail here…

Dim DocOne As Microsoft.Office.Tools.Word.Document

Dim DocTwo As Microsoft.Office.Interop.Word.Document


Perhaps I’m not correctly declaring. any suggestions would be greatly appreciated.

Many thanks in advance

--dd


Word 2013, RelativeHorizontalPosition does not work as it did in Word 2003

$
0
0

Hi all,

I am struggling with a small macro that is supposed to put a textbox in  the margin of a paragraph. This used to work just fine in Word97/2003 but somehow it does not in Word 2013. The text box ends up at the top left of the page. RelativeHorizontalPosition  and RelativeVericallPosition have no influence on the placement. Can't understand why...

Sub TekstVakInvoegen()

Application.ScreenUpdating = False Hoogte = CentimetersToPoints(1.27) ' Hoogte van Text Vak in points Breedte = CentimetersToPoints(4.1) ' Breedte van Text Vak in points PlaatsLeft = CentimetersToPoints(0) ' Plaats LEFT van Text Vak in points PlaatsTop = CentimetersToPoints(0) ' Plaats TOP van Text Vak in points Set myDoc = ActiveDocument Set myTextVak = myDoc.Shapes.AddTextbox(msoTextOrientationHorizontal, _ PlaatsLeft, PlaatsTop, _ Breedte, Hoogte, Selection.Paragraphs(1).Range) With myTextVak .RelativeHorizontalPosition = _ wdRelativeHorizontalPositionMargin .RelativeVerticalPosition = _ wdRelativeVerticalPositionParagraph .LockAnchor = True .Fill.BackColor = 0 .Fill.Visible = msoFalse .Fill.Transparency = 0# .Line.BackColor = RGB(255, 255, 255) .Line.Transparency = 0# .Line.Visible = msoFalse .LockAspectRatio = msoFalse .TextFrame.MarginLeft = 0# .TextFrame.MarginRight = 0# .TextFrame.MarginTop = 0# .TextFrame.MarginBottom = 0# .WrapFormat.Type = wdWrapNone .WrapFormat.Side = wdWrapBoth .WrapFormat.DistanceTop = CentimetersToPoints(0) .WrapFormat.DistanceBottom = CentimetersToPoints(0) .WrapFormat.DistanceLeft = CentimetersToPoints(0.32) .WrapFormat.DistanceRight = CentimetersToPoints(0.32) End With myTextVak.Select Selection.WholeStory Selection.Style = ActiveDocument.Styles("Tekst Vak Vet") Application.ScreenUpdating = True Application.ScreenRefresh End Sub


How to use documentbeforesaved method? And why my code doesn't work in template files?

$
0
0

Can someone help me with these two codes?

----Beginning of code 1-------------

Private WithEvents App As Word.Application

Private Sub Document_Open()
Set App = Word.Application
End Sub

Private Sub App_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
MsgBox("BeforeSave")
End Sub

--------------End of the code----------------

Beginning of code 2--------------- Code 2 is from https://msdn.microsoft.com/en-us/library/office/ff838299(v=office.15).aspx

Public WithEvents appWord as Word.Application 

Private Sub appWord_DocumentBeforeSave _ 
 (ByVal Doc As Document, _ 
 SaveAsUI As Boolean, _ 
 Cancel As Boolean) 

 Dim intResponse As Integer 

Private Sub App_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
MsgBox("BeforeSave")
End Sub
---------------------------------

In the first code, they have:

Private Sub Document_Open()
Set App = Word.Application
End Sub

 I test these two codes in "This document" object, and I find out the first code works but the second code are not!

Why second code doesn't work?

Extra question: I am using microsoft 2013. I insert this code into a macro-enabled template. But when I am about to save my file I am expecting these code works. However, they didn't work!

Thank you for solving these problem for me!

  

Headers on even and odd pages, VSTO

$
0
0

Hi,

I'm trying to crate word document. I created that header

MIDDLE-Text

Left header site Page 1 of 4

______________________________________________

but i want different headers at even and odd pages. My even hooter should looks like that but Left Table Text should be switched with Page 1 of 4. But when i did it Bottom Border go to footer... Conclusion : now i have odd headers like that and even switched but bottom border at footer. How can i fix even header?

Code which i use to create odd Headers

foreach (Word.Section section in wordDocument.Sections)
            {
                object TotalPages = Word.WdFieldType.wdFieldNumPages;
                object CurrentPage = Word.WdFieldType.wdFieldPage;
                wordApplication.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekCurrentPageHeader;
                wordApplication.ActiveWindow.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                wordApplication.ActiveWindow.Selection.Font.Size = 10;
                wordApplication.ActiveWindow.Selection.TypeText("MIDDLE-TEXT");
                wordApplication.ActiveWindow.Selection.Tables.Add(wordApplication.Selection.Range, 1, 2, false, true);
                wordApplication.ActiveWindow.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft;
                wordApplication.ActiveWindow.Selection.Font.Size = 8;
                wordApplication.ActiveWindow.Selection.TypeText("Left Table Text\nCompany address and so on");
                wordApplication.ActiveWindow.Selection.MoveRight(Word.WdUnits.wdCharacter, 1, ref oMissing);
                wordApplication.ActiveWindow.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight;
                wordApplication.ActiveWindow.Selection.Font.Size = 8;
                wordApplication.ActiveWindow.Selection.TypeText("Page ");
                wordApplication.ActiveWindow.Selection.Fields.Add(wordApplication.Selection.Range, ref CurrentPage, ref oMissing, ref oMissing);
                wordApplication.ActiveWindow.Selection.TypeText(" of ");
                wordApplication.ActiveWindow.Selection.Fields.Add(wordApplication.Selection.Range, ref TotalPages, ref oMissing, ref oMissing);
                wordApplication.ActiveWindow.Selection.MoveDown(Word.WdUnits.wdLine, 1, ref oMissing);
                wordApplication.ActiveWindow.Selection.Borders[Word.WdBorderType.wdBorderBottom].LineStyle = Word.WdLineStyle.wdLineStyleSingle;
                wordApplication.ActiveWindow.Selection.Borders[Word.WdBorderType.wdBorderBottom].LineWidth = Word.WdLineWidth.wdLineWidth050pt;
                wordApplication.ActiveWindow.Selection.Borders[Word.WdBorderType.wdBorderBottom].Color = Word.WdColor.wdColorBlack;
                wordApplication.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekMainDocument;
            }

Thanks for each advice.


Word 2013 and Active Directory attribut

$
0
0

Hi,

I'm working with WS2008R2 SP1 AD and Office standard 2013 and W7 SP1 x64. Our compagny wants to create .dotm/.dotx with automatic fields.

For example, we want that when a user opens a .dotx his name appears automatically. This one is easy it's the {AUTHOR \*MERGEFORMAT}.

But What we want to do is to do the same for the:

- street adress

- email adress

- the job title

All informations are in our Active Directory, but it seems that Word does not read directly the Active Directory info but some cached info on the computer.

So, is there a way or workaround to create some .dotx with the possibility to extrat some AD fields attribut attached with some user and at the end to build a semi automatic doc with the information of the user who has open this .dotx/.dotm?

So far, clues say that I have to write some vba script and 2 kind of solution/workaround:

The first lead is:

To retrieve the user account properties from Active Directory, we have to turn to some VBA scripts, no way to achieve this via any built-in features.

As far as I know, you can bind to the user account object by using the GetObject function and the LDAP provider.

Then use the GetInfo method to initialize the local cache with attributes of the user account object. This step will ensure that the most up-to-date attribute values of the ADSI object are retrieved.

For example:

Set objUser = GetObject _
("LDAP://...")
objUser.GetInfo

If you want to get this attributes when you create a new document based on a template (.dotx/.dotm), you'll need to use the AutoNew macro.

the second lead is:

http://heureuxoli.developpez.com/office/word/creermodele/#L2-G

Thank you in advance for any king od answer.

best regards


VB6 application crashes while trying to print microsoft word document using specific printers

$
0
0

I am using VB6 application to print MS word by loading all windows printers in my application. Irrespective of printing a document or not when I load these printers in a screen and cancel of the screen , I get below RTE:


Run-time error '-2147417848 (80010108)';
Automation error
The object invoked has disconnected from its clients.


Verified the Application Event log and found the below details:

Faulting application name: PiMS.exe, version: 8.1.0.0, time stamp: 0x546042e2
Faulting module name: ntdll.dll, version: 6.1.7601.18247, time stamp: 0x521ea8e7
Exception code: 0xc0000005
Fault offset: 0x000330bd
Faulting process id: 0xa4c
Faulting application start time: 0x01d03a7c78674f73
Faulting application path: C:\Program Files (x86)\CSC\i.PM\PiMS.exe
Faulting module path: C:\Windows\SysWOW64\ntdll.dll
Report Id: 61d95797-a670-11e4-9bf2-005056ab746a

Fault bucket , type 0
Event Name: APPCRASH
Response: Not available
Cab Id: 0

Problem signature:
P1: PiMS.exe
P2: 8.1.0.0
P3: 546042e2
P4: ntdll.dll
P5: 6.1.7601.18247
P6: 521ea8e7
P7: c0000005
P8: 000330bd
P9:
P10:

We believe the runtime error can happen at different times depending if the corrupted print queue is default and its position in the printers list. The error is caused by HP Color LaserJet CM6040 MFP PCL6 print queue, because once we stopped mapping this printer via RDP session, the application did not crash.  

How to resolve this error.

Relationship of .dot to .doc files?

$
0
0

There is a small Word application embedded in my PowerBuilder application. I have never worked with Word programming, although I'm familiar with VBA via MS Access, and once long ago from Excel. My question is, how do the .dot and .DOC files relate to each other? I put a break point at the top of the .dot macro and expected it to execute when I opened the .doc file. Didn't do it. In Excel and Access, the VBA is accessed via the end product, a letter or a spreadsheet. And is executed when those objects are opened. How does it work in Word?

TIA

LAS

Mail merge via COM automation with directory template

$
0
0

Hi All

If you setup a directory list merge temple in Word, associate it with a CSV file and run a merge it works as you would expect

If you take this same template and open it via COM, associate the data source with it and perform a merge .... you get one record per page instead of multiple ?

Is this a know issue ?

How does one get around it ?

Thanks

Force Add-in Loading Timeout

$
0
0

I have a shared add-in that calls a WCF service on load. When the service is not reachable the add-in stalls on the word splash screen for exactly 20 seconds. I want to somehow force the add-in to shorten the time spent trying to connect the service when is not available.

I've tried adding timeout parameters to the custom binding for the WCF service:

receiveTimeout="00:00:01" sendTimeout="00:00:01" openTimeout="00:00:01"

But this had no effect, and I honestly don't want to permanent alter the connection settings across the entire app just to resolve this startup issue.

Is there something I can add to OnConnection to stop the add-in from trying to load after a certain amount time?



Viewing all 4350 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>