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

how can i distinguish the multi-level heading?

$
0
0

i want to find all of the multi-level heading in the document, but it is difficult for me to finding the diff between some headings. 

look the below picture, the heading 1("Head1_M") has applyed multi-level style, and the heading 2("head2") has set to none.

i want to get heading 1 but exclude the heading 2, how can i do it?


develop use word2010.  thanks.


Manipulating Fonts Within a Textbox Using VBA

$
0
0

Hello:

I have an Excel application that opens up a 2010 Word Document which contains an empty textbox.  From Excel, I insert text into the Word's textbox object.  The text inserts correctly and it all assumes the font and size originally set in Word for that textbox.

Is there a way to select certain text within that textbox and change the font so that the textbox contains multiple font types?  I can do it manually from within Word, but not sure how to accomplish that from Excel's VBA interface.

If you take a quick look at this code, there is a note where I want to manipulate the fonts inside the textbox:

Option Explicit
Dim strFilePathWord As String
Dim dlgOpenFile As FileDialog
Dim intNoOfRows
Dim intNoOfColumns
Dim objWord As Word.Application
Dim objDoc As Word.Document
Dim objRange As Word.Range
Dim shp As Word.Shape
Dim i As Integer
Dim j As Integer
Dim strMyData As String
Dim wkbThisWorkbook As Workbook
Dim wksDataToTransfer As Worksheet

Public Sub WriteToTextBoxExisting()

Set wkbThisWorkbook = ThisWorkbook
Set wksDataToTransfer = wkbThisWorkbook.Sheets("SampleData")

' *******************************************************
' Get An Existing Word Doc File Name and Path
' *******************************************************
Call SelectWordDocumentToOpen

If strFilePathWord = "" Then
    MsgBox ("No File Selected")
    Exit Sub
End If

' *******************************************************
' Build A String Containing Excel Row & Column Data
' *******************************************************

intNoOfRows = 26
intNoOfColumns = 2

For i = 1 To intNoOfRows
     For j = 1 To intNoOfColumns
        If j = 1 Then
            strMyData = strMyData & wksDataToTransfer.Cells(i, j).Value & vbTab
        Else
            strMyData = strMyData & wksDataToTransfer.Cells(i, j).Value & vbCrLf
        End If
     Next j
Next i

' *******************************************************
' Create The Word Objects from Excel And Open An
' Existing Word Document
' *******************************************************
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Open(strFilePathWord)

' *******************************************************
' Insert Text Into A Textbox
' Set Up Bullets Before loading text into textbox
' *******************************************************
For Each shp In objDoc.Shapes
    If shp.Name = "Text Box 11" Then
        Call SetUpBullets
        shp.TextFrame.TextRange.Text = strMyData
    End If
Next

' *******************************************************
' At This Point I Would Like Select Certain Lines within
' The Textbox and Assign a Different Font
' *******************************************************

End Sub

Private Sub SelectWordDocumentToOpen()

strFilePathWord = ""
Set dlgOpenFile = Application.FileDialog(msoFileDialogOpen)
With dlgOpenFile
    .AllowMultiSelect = False
    .Filters.Clear
    .Filters.Add "Word Document", "*.docx"
    .Filters.Add "2003 Word Document", "*.doc"
    .FilterIndex = 1
    .Show
    If .SelectedItems.Count < 1 Then
        Exit Sub
    End If
    strFilePathWord = .SelectedItems(1)
End With

End Sub

Private Sub SetUpBullets()
  With objWord.ListGalleries(wdBulletGallery).ListTemplates(1).ListLevels(1)
        .NumberFormat = ChrW(61558)
        .TrailingCharacter = wdTrailingTab
        .NumberStyle = wdListNumberStyleBullet
        .NumberPosition = objWord.InchesToPoints(0.25)
        .Alignment = wdListLevelAlignLeft
        .TextPosition = objWord.InchesToPoints(0.5)
        .TabPosition = wdUndefined
        .ResetOnHigher = 0
        .StartAt = 1
        .Font.Name = "Wingdings"
        .LinkedStyle = ""
    End With
    objWord.ListGalleries(wdBulletGallery).ListTemplates(1).Name = ""
    shp.TextFrame.TextRange.ListFormat.ApplyListTemplateWithLevel ListTemplate:= _
        ListGalleries(wdBulletGallery).ListTemplates(1), ContinuePreviousList:= _
        False, ApplyTo:=wdListApplyToSelection, DefaultListBehavior:= _
        wdWord10ListBehavior
End Sub

Thanks,



Rich Locus, Logicwurks, LLC

http://www.logicwurks.com

I would like to use Office 2013 as a front end HTML layout tool for Visual Studio 2013

$
0
0

I am looking for a WUSIWUG editor that will make the spacing and laying out web pages easier.

It would also make it easier for clients to make screen modifications and send them back to me.

I want to use those HTML pages in Visual Studio 2013 for adding code behind and debugging.

In the past when I have tried this, I have had two problems.

The first is that spacing issues did not work out well.  I am hoping that with Office 2013 that has been fixed.

Second, Word after working the HTML file in Visual Studio 2010 HTML had some problems opening the file.   It was not too happy to share with VS.  It did not nicely load HTML documents.  

Also filtered HTML would lose the proper spacing of items on the page.

There were also issues in that if you used the unfiltered HTML it put a lot of code in there that the browsers had problems with.

Has anyone used Word 2013 for this purpose and how were the results?

One of the reasons I want to do this, is that it is easier for customers to Modify things in Word than in HTML.   It is also easy in word to cut and past images and other items on the page.  

Number formating problems

$
0
0

When editing an existing Voice Recognized word document I'm not able to format the numbering so that the text on the second and following lines indents to the same tab that the first line does.

I'm assuming that is because of the way the document was originally formatted.

Is there a way to correct this?

is multilevel list can mix number and charecter?

$
0
0

i want to build a multilevel list template like below:

just the level 1 contain chinese charecter, other levels all combine by Arabic numbers.

is word can do it?

i don't find the way to reach my aim. if i change the level1, all of sublevel will contain level1's Simple Chinese Char.


System.Runtime.InteropServices.COMException CLSID {000209FF-0000-0000-C000-000000000046} Error: 80040154

$
0
0

I got the following exception.

"System.Runtime.InteropServices.COMException (0x80040154):
Retrieving the COM class factory for component with CLSID
{000209FF-0000-0000-C000-000000000046} failed due to the following error:
80040154."

i got error at this code

"Word.Application objWord = new Word.Application();"

whats the actual issue is? and how to solve this?


J.H.Ramavat

Office will coerces SaveAs path to user's Documents directory

$
0
0

I have a VB6 program that allows use of a created object instance of MS Word to produce letters and automatically save them in the appropriate directory as determined by my program, for example:

objMSWordDocument.SaveAs C:\DISC\VER70\LOAN\DATA2\2\3\00049323.01\LETTERS\20140428124003.docx , wdFormatXMLDocument

This works as designed on one machine running Windows 8.1 Professional 64-bit, but on another identical machine, instead of silently saving the document to the specified location, a Save Dialog opens that points to the Windows user's Documents directory.

I assume this is a permissions issue, either in MS Word, or Windows 8.1. My program is set to Run as Administrator.

Remove space in Header

$
0
0

I have a table in my header and it forces a into the next line with a pargraph marker but I need this table to be flush with the body of the document which has its own border. How can I remove that?


Adding Section Headings and updating TOC in Word using vb.net

$
0
0

I am trying to Automate the Word document using VB.net

I am trying to find an example that can show me how to update the word document with Sections and Section headings. Once the sections are created it should be updated in Table of Contents. (As simple as that).

But the problem is I am not sure of the syntax to be used associated with Sections.

I have done the following using vb.net

1) I have created the Word document 2) Added some Paragraphs 3) Created some Tables & Figures Charts,...blah..blah

What I am trying to do now:

  • Define Sections
  • Add Section Heading
  • Update the Headings created in the Table of Contents before closing the Document.

i.e,. For Example

  1. Introduction

1.1 Mechanical

1.2 Electrical

2. Test Conditions

Update this in TOC as

  1. Introduction .... 1

1.1 Mechanical .... 2

1.2 Electrical ..... 4

2. Test Conditions


I already know how to update the TOC as mentioned below:

With oDoc
            .TablesOfContents.Add(Range:=oWord.Selection.Range, _
                       RightAlignPageNumbers:=True, _
                       UseHeadingStyles:=True, _
                       IncludePageNumbers:=True, _
                       AddedStyles:="styleSection", _
                       UseHyperlinks:=False, _
                       HidePageNumbersInWeb:=True, _
                       UseOutlineLevels:=True)
            .TablesOfContents(1).Range.Font.Name = "Arial Narrow"
            .TablesOfContents(1).Range.Font.Size = 11
            .TablesOfContents(1).TabLeader = Word.WdTabLeader.wdTabLeaderDots
            .TablesOfContents.Format = Word.WdTocFormat.wdTOCSimple

End With

        oDoc.TablesOfContents(1).Update()
        oDoc.TablesOfContents(1).UpdatePageNumbers()

But all I am trying to find now is how to add Sections and add text as section headings ?! I did lot of search on this but not able to find the right solution.

The Below code doesn't seems to work ->

Dim oWord As Word.Application
Dim oSection As Word.Section

oSection = oDoc.Sections.Add
oSection.Range.Text = "INTRODUCTION"
oSection.Range.InsertAfter("This is Section 1")

Selection.MoveDown wdLine, 4, wdExtend doesn't work for one customer with Word 2013

$
0
0

Hello,

I have a problem with one of our many clients. We have an "old" software written in VB6.0 that uses Word automation. Since the software runs on various Windows-Plattforms with different Windows- and Office-versions it uses late binding. Usually we have relativly few problems and if we have them, they often happen to all users with a special version or patch level or else happen to more than one customer.

Now I have the situation, that I have only one customer, who uses Office 2013 Home & Business, that has exactly one line of code seemingly not working (but not raising an error either).

The code snippet is as follows:

mDocument.Application.Selection.GoTo wdGoToBookmark, , , Bookmark
mDocument.Application.Selection.SelectRow
If Bookmark = "Anlage7" Then
   mDocument.Application.Selection.MoveDown wdLine, 4, wdExtend
   MsgBox mDocument.Application.Selection.Text, vbOKOnly, "Debug"   'just to see what's selected
End If
mDocument.Application.Selection.Copy

Problem is the line  "mDocument.Application.Selection.MoveDown wdLine, 4, wdExtend", where "mDocument" is declared as "Word.Document". The variable "Bookmark" is set to "Anlage7" externally.

The lines to select are in a table where one "row" internally consists of 5 rows and some fields are merged in some columns. So the first ".SelectRow" selects the actual first row and the ".MoveDown" is supposed to select the rest of the "row".

It is working perfectly well in my various test environments with various Word versions and also with our other customers with various Word versions, even with Word 2013. Only for one customer it doesn't work, there is allways only the first row selected.

I have read, that using the "Selection" might not be the best idea, that "Range" might be better, but the code is working for over  10 years now and the saying is "never touch a running system", isn't it?

Has anyone an idea what could be the problem here?  Thanks in advance.

Issue While Extract the Embedded Object present inside word 2010 file.

$
0
0
Dear Friends,

I have developed application c#.Net 2008, 

Step 1. It will open the word file and find the embedded object(*.m file) in it.

Step 2. That embedded object (*.m file) is copied to clipboard.

Step 3. Getting the embedded object(*.m file) from clipboard.

Step 4. Reading the embedded object(*.m file) content and saving it back to hard disk as (*.m) file.

My application is worked fine for word 2003 and files are got saved in hard disk, but the issue is application fails for word 2010.

My application fails for word 2010 for Step 3.

Following code works for word 2003 but fails for word 2010.

foreach (Word.InlineShape inlineShape in wordDoc.InlineShapes)
{
 Clipboard.Clear();
 outputFile = null;
if (inlineShape.Type == Word.WdInlineShapeType.wdInlineShapeEmbeddedOLEObject)
{
if (inlineShape.OLEFormat != null)
{
if (inlineShape.OLEFormat.ProgID == "Package")
{

nTotalInlineShapeCount++;
inlineShape.Select();
wordApp.Selection.Copy();

IDataObject iData = Clipboard.GetDataObject();
if (iData != null)
{
string name = iData.ToString();
string objType = "Native";
object objToSave = iData.GetData(objType);

Clipboard.SetDataObject("");
Clipboard.Clear();

MemoryStream objStream = (MemoryStream)objToSave;
long sizeOfMyObj = objStream.Length;

Kindly help me to solve the above issue.

Thanks in advance.

Sharing Doc based on the same Template between different users/computers

$
0
0

Hi,

I would like to be able to share Word documents (2007 and later)  based on the same template between different users on the same computer or between users with different computers.

Normally in my computer the template is located in C:\Users\ My user name \AppData\Roaming\Microsoft\Templates

I discovered a Word behavior that surprised me.

1) If I create a doc based on the same template (and same name) but located in a different folder, when I look in the Developer Tab>Document Template, I can see the different folder as expected, but after I close and reopen the file I see (unexpectedly) that the template associated is the one in the canonical folder. 

2) If a different user on the same computer doesn't have the template in the same non canonical folder the macros are disabled and the template associated is the old one. But if the other user as the same template (and same name) in C:\Users\ Other user name \AppData\Roaming\Microsoft\Templates, all the macros will work and the template associated is the one in the canonical folder with  ...\ My user name \... changed  to ...\ Other user name \...

That behavior is not necessarily bad, on the contrary it will save me a lot of work (Since I need to manipolate those file from Acces, I was thinking to write a procedure for checking and changing the attached Template, before to be able to work on them).

But how relayble is it? Does it depend on some Word options that could be set differently on other computers?

Thanks, Lauro

Word couldn't send mail because of MAPI failure, Unspecified error.

$
0
0

This issue is crossposted in Microsoft Answers Word and OUTLOOK.  I am posting here in hopes that someone at Mircrosoft may have a solution or at least elevate the issue to someone who does.

http://answers.microsoft.com/en-us/office/forum/officeversion_other-word/word-could-not-send-mail-because-of-mapi-failure/f62678fe-ef1d-42b5-8cfe-1e43d6a1d609

http://answers.microsoft.com/en-us/office/forum/office_2013_release-outlook/word-couldnt-send-mail-due-to-mapi-failure/1f03cf74-9258-411b-9e2b-e41cb5006d71

I dabble with VBA and write and maintain several amateur Word Add-Ins.  Accordingly, I have Word 2003, 2007, 2010 and 2013 installed on my PC.  They get along fine.  However, I am unable to "Share" or "Send" an open Word document as an E-mail attachment in any version!  In each case Word returns an error mesage "Word couldn't send mail because of a MAPI failure, Unspecified error (the same issue occurs with Excel and Powerpoint except the error dialog is a bit different.)

Using Word 2003, I (CAN) "Send to (Mail recipient for review)" in which case OUTLOOK is opened with the document as an attachment.  I can also "Send to Mail Recipient" from Windows Explorer, in which case the Word file is attached to an OUTLOOK message, and I can create an instance of OUTLOOK and send mail from Word using VBA.

I have repaired all Office versions.  I have removed the registry keys for all office versions and repaired all versions again.  I have run "fixmapi" until I am blue in the face. I have renamed the MAPI32.DLL files and ran sfc \scannow to ensure that the MAPI32.DLL file is not corrupt.  In view of these actions and in view of what I can do, something tells me that the MAPI files are fine.

So what is this "Unspecified error?"  This problem is rife on the internet and most of the "canned" solutions have been marked "Answered" by some MS support engineer.  These "canned" solutions might have fixed the issue at one point, but they don't work now.  At least not for me.

Thanks.

 

 


Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm

Ask prompt \o switch doesn't work in macro

$
0
0

How do I get the Ask prompt \o switch to work correctly when executing mail merge from a macro? I'm running mail merge from word.  The mail merge document has an Ask prompt with the \o switch telling it to ask only once.  When running the mail merge directly from Word, the prompt appears only once.  When executing the mail merge within a macro, the prompt appears for every record.  The user will run the mail merge from either Word or use the macro, depending on the scenario. 

Thanks for your assistance.

Trouble with tables

$
0
0

I need to do either:

1. Have a row whose min height spans between two pages without the document pushing the cell to the next page.

2. Have border around entire document and footer but not the header

I cant seem to do either solution


Word Viewer in asp.net

$
0
0

I want to make word document viewer  which can open the word document file in the browser , 

so please anyone have the solution so, please share with me  .

thanks

Adding Section Headings and updating TOC in Word using vb.net

$
0
0

I am trying to Automate the Word document using VB.net

I am trying to find an example that can show me how to update the word document with Sections and Section headings. Once the sections are created it should be updated in Table of Contents. (As simple as that).

But the problem is I am not sure of the syntax to be used associated with Sections.

I have done the following using vb.net

1) I have created the Word document 2) Added some Paragraphs 3) Created some Tables & Figures Charts,...blah..blah

What I am trying to do now:

  • Define Sections
  • Add Section Heading
  • Update the Headings created in the Table of Contents before closing the Document.

i.e,. For Example

  1. Introduction

1.1 Mechanical

1.2 Electrical

2. Test Conditions

Update this in TOC as

  1. Introduction .... 1

1.1 Mechanical .... 2

1.2 Electrical ..... 4

2. Test Conditions


I already know how to update the TOC as mentioned below:

With oDoc.TablesOfContents.Add(Range:=oWord.Selection.Range, _
                       RightAlignPageNumbers:=True, _
                       UseHeadingStyles:=True, _
                       IncludePageNumbers:=True, _
                       AddedStyles:="styleSection", _
                       UseHyperlinks:=False, _
                       HidePageNumbersInWeb:=True, _
                       UseOutlineLevels:=True).TablesOfContents(1).Range.Font.Name ="Arial Narrow".TablesOfContents(1).Range.Font.Size =11.TablesOfContents(1).TabLeader = Word.WdTabLeader.wdTabLeaderDots.TablesOfContents.Format = Word.WdTocFormat.wdTOCSimpleEndWith

        oDoc.TablesOfContents(1).Update()
        oDoc.TablesOfContents(1).UpdatePageNumbers()

But all I am trying to find now is how to add Sections and add text as section headings ?! I did lot of search on this but not able to find the right solution.

The Below code doesn't seems to work ->

Dim oWord As Word.ApplicationDim oSection As Word.Section

oSection = oDoc.Sections.Add
oSection.Range.Text ="INTRODUCTION"
oSection.Range.InsertAfter("This is Section 1")

Forcing users to use a specific naming convention

$
0
0

Hello,

my organization has implemented some naming conventions for documents. Very simple things like no spaces ect. Is there a way to impose these conventions on users in Ms Word 2010. Ie) Can the system generate a warning if the file name doesn't meet the naming convention when a user tries to save?

Thanks,

Page 1 of X

$
0
0

I would like Page 1 of X on my first page but it cant be part of the header.

Is it possible to have that feature not in the header?

How to reference SharePoint Workflow task in MS Word 2010?

$
0
0

Hello,

Here is my challenge:
There is a workflow that is running in Sharepoint 2010 and associated with Word 2010 document. Once the document is opened the user can click on the button within Word "Open this Task". Once it is clicked the popup window appears that displays InfoPath form from the workflow.

What I need to do is to:

1. Check to see if there is workflow task is pending for any given document

2. If it is pending on Close event I'd like to launch that InfoPath form so user is forced to complete the tasks

3. If workflow task is not pending the user closes the Word file.

Any help is appreciated.
Thank you.


vlad

Viewing all 4350 articles
Browse latest View live


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