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

Style object slowness on Word 2013

$
0
0

I developed a Word add-in that needs to read the Style object of each character of the document body. The add-in is working, but in Word 2013 it executes extremely slow. I tested in Word 2007 and Word 2010 and it works alright.


So I decided to do a test. Given a small text, consider this small piece of code:

Sub fncSpeedTest()
  Dim prg As Word.Paragraph
  Dim rng As Word.Range
  Dim objStyle As Word.Style
  Dim objBorders As Word.Borders
  Dim sngTime As Single
  sngTime = VBA.Timer
  For Each prg In ActiveDocument.Content.Paragraphs
    For Each rng In prg.Range.Characters
      'Test 1: <nothing>
      'Test 2:
      'Set objBorders = rng.Borders
      'Test 3:
      'Set objStyle = rng.Style
    Next rng
  Next prg
  VBA.MsgBox VBA.Format((VBA.Timer - sngTime) * 1000, "#,##0") & " milliseconds.", vbInformation
End Sub

Test 1 just run the entire document. I got 238 milliseconds.

Test 2 accesses the borders object of each character, I got 313 milliseconds. That's fair.

Test 3 reads the style object of each character, and I got a large number: 51441 milliseconds.

Do anyone know about this slowness on Word 2013 or there is something I'm missing?

What results you gort in 2007, 2010 or 2013 versions?

---

By the way, if you want to see the add-in, it is free and open source, the link is http://www.ambienteoffice.com.br/word/word2html/ and the download link is at the bottom of the page. I hope you understand the page after automatic translation. The purpose of the add-in is to convert document body text into HTML body elements, but in a cleaner way than Word saves to HTML. My e-mail is at the bottom of the page. Any feedbacks would be appreciated.


Felipe Costa Gualberto - http://www.ambienteoffice.com.br


How can I hide the Excel when I update charts in word by C#>

$
0
0
private void butChart_Click(object sender, EventArgs e)
{
object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "//endofdoc"; /* /endofdoc is a predefined bookmark */
object remarkOverTable = "chy";

//Start Word and create a new document.
Microsoft.Office.Interop.Word._Application oWord;
Microsoft.Office.Interop.Word._Document oDoc;
oWord = new Microsoft.Office.Interop.Word.Application();
oWord.Visible = true;
object Template = Application.StartupPath + @"\chy.docx";
oDoc = oWord.Documents.Add(ref Template, ref oMissing,
ref oMissing, ref oMissing);

//得到书签
Microsoft.Office.Interop.Word.Bookmark mark = oDoc.Bookmarks.get_Item(ref remarkOverTable);

//清理excel进程类
ExcelProcessManager pm = new ExcelProcessManager();
pm.Lock();

//重点在这句话上,强制转换成 Interop.Word.InlineShapes
Interop.Word.InlineShapes inlineShapes = (Interop.Word.InlineShapes)mark.Range.InlineShapes;

if (inlineShapes.Count > 0)
{
try
{
object Name = new object();

Name = mark.Name;

Object[,] obj = new Object[11, 3];
// fill data to obj
/* ------------------------------------
* | | 收入 | 支出 |
* ------------------------------------
* | 2012/03/01 | 1023.2 | 304.23 |
* -------------------------------------
* | 2012/03/02 | 1123.2 | 314.23 |
* -------------------------------------
* | 2012/03/03 | 1223.2 | 674.23 |
* -------------------------------------
* | 2012/03/04 | 1043.2 | 124.23 |
* -------------------------------------
* | 2012/03/05 | 1083.2 | 384.23 |
* -------------------------------------
* | 2012/03/06 | 923.2 | 404.23 |
* -------------------------------------
* | 2012/03/07 | 2023.2 | 305.23 |
* -------------------------------------
* | 2012/03/08 | 1623.2 | 303 |
* -------------------------------------
* | 2012/03/09 | 1403.2 | 314.23 |
* -------------------------------------
* | 2012/03/10 | 1003.2 | 340 |
* -------------------------------------
*/
//添加横向第一列作为标题
obj[0, 0] = string.Empty;
obj[0, 1] = "收入";
obj[0, 2] = "支出";

DateTime dt = new DateTime(2012, 3, 1);
Random rnd = new Random();
int last = 1000;
// fill data
for (int i = 1; i < 11; i++)
{
obj[i, 0] = dt.ToString("yyyy/MM/dd");
obj[i, 1] = last + rnd.Next(i, 100);
obj[i, 2] = last - rnd.Next(i, 100);
last = (int)obj[i, 1];
dt = dt.AddDays(1);
}

//成功找到图表
Interop.Word.Chart chart = inlineShapes[1].Chart;

ChartUpdate(chart, Name.ToString(), obj);
}
catch (Exception ex)
{

}
}
pm.Release();
}


 /// <summary>
/// 更新图表数据
/// </summary>
/// <param name="chart"></param>
/// <param name="bookMark"></param>
/// <param name="dataArr"></param>
protected void ChartUpdate(Interop.Word.Chart chart, string bookMark, Object[,] dataArr)
{
if (chart == null)
{
//logger.Warn("Word.Chart is null!");
return;
}

if (dataArr == null)
{
//logger.Warn("Data is null!");
return;
}

Object oMissing = System.Reflection.Missing.Value;
Interop.Word.Chart chrt;
Microsoft.Office.Interop.Excel.Workbook wb = null;

Object bk = bookMark;
try
{
//xlApp.ScreenUpdating = false;
chrt = chart;

if (chrt.ChartData == null)
{
//logger.Warn("chart.ChartData is null!");
return;
}

chrt.ChartData.Activate();//////////////////////////////////////Look at this step.When this code run,The Excel.exe will 'jump out'
wb = (Excel.Workbook)chrt.ChartData.Workbook;///////////////////////////

if (wb == null)
{
//logger.Warn("chart.ChartData.Workbook is null!");
return;
}
wb.Application.ScreenUpdating = false;
wb.Application.WindowState = Microsoft.Office.Interop.Excel.XlWindowState.xlMinimized;

Microsoft.Office.Interop.Excel.Worksheet wSh = (Excel.Worksheet)wb.Worksheets[1];

if (wSh == null)
{
//logger.Warn("chart.ChartData.Workbook.Worksheets[1] is null!");
return;
}

// save formats
wSh.Cells.ClearContents();
Microsoft.Office.Interop.Excel.Range Rng = wSh.get_Range("A1", "A1");
Rng.get_Resize(dataArr.GetUpperBound(0) + 1, dataArr.GetUpperBound(1) + 1).Value2 = dataArr;
chrt.SetSourceData("'Sheet1'!" + Rng.get_Resize(dataArr.GetUpperBound(0) + 1, dataArr.GetUpperBound(1) + 1).get_Address(Type.Missing, Type.Missing, Excel.XlReferenceStyle.xlA1, Type.Missing, Type.Missing), Type.Missing);
chrt.Refresh();
wb.Application.ScreenUpdating = true;

wb.Close(Type.Missing, Type.Missing, Type.Missing);
}
catch (System.Runtime.InteropServices.COMException ex)
{
//logger.Warn("Update chart failed!", ex);
//xlApp.ScreenUpdating = true;
}
finally
{
if (wb != null)
{
try
{
Marshal.ReleaseComObject(wb);
}
catch { }
}
}
} 
//clean excel process
private class ExcelProcessManager
{
private bool _exits;
public ExcelProcessManager() { }

public void Lock()
{
_exits = Process.GetProcessesByName("EXCEL").Length > 0;
}

public void Release()
{
if (_exits)
return;

Process[] excelproc = Process.GetProcessesByName("EXCEL");
if (excelproc.Length > 0)
excelproc[0].Kill();
}
} 

I can update Excel charts data .The problem is there are 18 charts in my word .And the Excel.exe will jump out 18 times!

Can hide the Excel.exe ? 

chrt.ChartData.Activate();//////////////////////////////////////Look at this step.When this code run,The Excel.exe will 'jump out'wb = (Excel.Workbook)chrt.ChartData.Workbook;


赵召

office shared Add-in using C#. not show button.

$
0
0

Hi,

I am trying to use  C# in visual studio 2010 to build the an application for office shared in project,

I follow the link (support.microsoft.com/kb/302901/en_us )to created the project, after not button show in office word, I don't know why.

Thanks

Can I close Excel dialog when I operate the charts in Word document By using Microsoft.Office.Interop.Excel and Microsoft.Office.Interop.Word?

$
0
0

/// <summary> /// 更新图表数据 /// </summary> /// <param name="chart"></param> /// <param name="bookMark"></param> /// <param name="dataArr"></param> protected void ChartUpdate(Interop.Word.Chart chart, string bookMark, Object[,] dataArr) { if (chart == null) { //logger.Warn("Word.Chart is null!"); return; } if (dataArr == null) { //logger.Warn("Data is null!"); return; } Object oMissing = System.Reflection.Missing.Value; Interop.Word.Chart chrt; Microsoft.Office.Interop.Excel.Workbook wb = null; Object bk = bookMark; try { //xlApp.ScreenUpdating = false; chrt = chart; if (chrt.ChartData == null) { //logger.Warn("chart.ChartData is null!"); return; } chrt.ChartData.Activate(); wb = (Excel.Workbook)chrt.ChartData.Workbook; if (wb == null) { //logger.Warn("chart.ChartData.Workbook is null!"); return; } wb.Application.ScreenUpdating = false; wb.Application.WindowState = Microsoft.Office.Interop.Excel.XlWindowState.xlMinimized; Microsoft.Office.Interop.Excel.Worksheet wSh = (Excel.Worksheet)wb.Worksheets[1]; if (wSh == null) { //logger.Warn("chart.ChartData.Workbook.Worksheets[1] is null!"); return; } // save formats wSh.Cells.ClearContents(); Microsoft.Office.Interop.Excel.Range Rng = wSh.get_Range("A1", "A1"); Rng.get_Resize(dataArr.GetUpperBound(0) + 1, dataArr.GetUpperBound(1) + 1).Value2 = dataArr; chrt.SetSourceData("'Sheet1'!" + Rng.get_Resize(dataArr.GetUpperBound(0) + 1, dataArr.GetUpperBound(1) + 1).get_Address(Type.Missing, Type.Missing, Excel.XlReferenceStyle.xlA1, Type.Missing, Type.Missing), Type.Missing); chrt.Refresh(); wb.Application.ScreenUpdating = true; wb.Close(Type.Missing, Type.Missing, Type.Missing); } catch (System.Runtime.InteropServices.COMException ex) { //logger.Warn("Update chart failed!", ex); //xlApp.ScreenUpdating = true; } finally { if (wb != null) { try { Marshal.ReleaseComObject(wb); } catch { } } } }

Look at this fragment code:

chrt.ChartData.Activate();
wb = (Excel.Workbook)chrt.ChartData.Workbook;

if (wb == null)
{
//logger.Warn("chart.ChartData.Workbook is null!");
return;
}
wb.Application.ScreenUpdating = false;
wb.Application.WindowState = Microsoft.Office.Interop.Excel.XlWindowState.xlMinimized;

Microsoft.Office.Interop.Excel.Worksheet wSh = (Excel.Worksheet)wb.Worksheets[1];

The problem is that .I want to change the data of the chart ,so I must open the Excel.exe.But every time ,the Excel will show a dialog ,so I can't update the data of chart .I must close the dialog by hand?Can I close the dialog of Excel by c#?Or Can Prevent the dialog from showing? I just want to update the charts data.



赵召

Deleting objects from a Microsft Word document

$
0
0

I have a MS word document (template). My program asks the user questions and based on those questoins it fills out the template for them programmatically.

Some of the questions on the template requires the user to circle an answer. Instead of making the user do double work, I circled all possible answers. Since I know what the user answered in my program, I would like to know if there is a way to go throug the template and delete certain drawing objects (the circles around the text).

Can I give each object an ID number in word and tell my program delete objects out of the document that match that ID number?

Thanks in advance for your assistance.


-Nothing to see. Move along.

how can i loop the Repeating Section Content Controls using vb.net

$
0
0

I have a Repeating Section Content control.

Like in the image : In first line i have placed Repeater control.Currently it has 4 xml nodes inside.

i need to Print the data based on xml nodes and as well as below (10)lines by inserting new repeater control for each time.

i have followed below code : But this is not correct. 

For Each XMLNode1 In wordApp.ActiveDocument.ContentControls
            If XMLNode1.Type = Microsoft.Office.Interop.Word.WdContentControlType.wdContentControlRepeatingSection Then
                XMLNode1.Range.Text = "Note"
     End If
        Next

Can i have sample in vb.net for Repeating  the Repeating Section Content control and inserting new Repeating Section Content control.




Is it possible to customize the background of a Word-Document?

Tabbing order in checkbox content controls in Word 2013 and 2010

$
0
0

I added a series of checkbox content controls to a Word2013 document, NOT a dialog box. When I click one of the checkboxes, the focus shifts to the SECOND checkbox in the series, NOT the NEXT checkbox.

I added some Visual Basic msgboxes to the OnEnter and OnExit events in the document to display the Title and Tag of the ContentControl that is being entered or exited. This shows that the focus DOES shift the the next checkbox in the series but it exits the checkbox immediately and enters the next box, which is the second box after the box clicked. In other words, it appears the focus is moving correctly from one box to the next, BUT the focus does not remain in the next box but quickly moves out of it.

I have tried the document in both Word 2013 and 2010, and the behavior is the same.

Is this a bug, or do I need to add code to prevent this?

Thanks,

Van


Error 4198

$
0
0
I started making a macro in MS Excel. User VBA and my code looks like this. 

Sub Knap1_Klik () 
Dim paragraphe As Object 

Dim objWord As Object 
Set objWord = CreateObject ("Word.Application") 

objWord.Documents.Open ("C: \ Users \ Steffen \ Desktop \ Dim wbk As Workbook.docx") 

        
End Sub 

My problem is if I press cancel and close word I get the following error Run-time error '4198 '

How do I fix this

How do I get the o:title property in Word VBA?

$
0
0

I have a Word 2003 .doc file with many embedded images.

The way I use to find out the names of the files these came from is to save the doc as a Web page .htm.

I can look in the _files folder for the images.

In the .htm file I can see data like

<!--[if gte vml 1]><v:shape id="_x0000_i1042" type="#_x0000_t75"
 style='width:260.25pt;height:183.75pt'>
 <v:imagedata src="Docname_files/image035.jpg"
  o:title="ps IMG_8147"/>

The one of interest is o:title, showing that it came from "ps IMG_8147.JPG"

Is there a way to see that property from a Word macro? 

I have tried Selection.InlineShapes(1).AlternativeText

but that is often blank. I can't see a .Title property in Word 2003 VBA.

Any ideas?

Thanks

Patrick

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

Adding text after inserting a field with VBA

$
0
0

I have been trying to insert combinations of text and fields in a Word header using the Range object. If I insert the fields manually there is no problem: After the insertion the cursor is behind the field, so further elements can be added. But if I use VBA, for some fields the cursor remains in from of the field.

The three subroutines below illustrate this problem:

In the first texts and fields are added sequencially, but only the FileName field is positioned properly, the Date, Page and NumPage fields appear in reverse order.

In the second sub I have updated the range object after each insertion of these fields. This works, but is not beautiful and would not work if applied in the middle of a document.

In the third version insertions are made in reverse order. This works fine, but the code is more difficult to comprehend.

So my questions are:

  • How can I easily get behind a newly inserted field?
  • Why do fields behave different from each other when inserted by code?

Best wishes

Holger Nielsen

Denmark

 

 

 

Sub CreateHeaderForwardsNotOk()

   Dim doc As Word.Document, rng As Word.Range

   Set doc = ActiveDocument

   Set rng = doc.Sections(1).Headers(wdHeaderFooterPrimary).Range

   With rng

       .Fields.Add Range:=rng, Type:=wdFieldFileName, PreserveFormatting:=True

'       .Collapse wdCollapseEnd

       .InsertAfter (" ")

       .Collapse wdCollapseEnd

       .Fields.Add Range:=rng, Type:=wdFieldDate, Text:="\@ YYYY-MM-DD", PreserveFormatting:=True

       .Collapse wdCollapseEnd

       .InsertAfter (vbTab)

       .Collapse wdCollapseEnd

       .InsertAfter (":-(")

       .Collapse wdCollapseEnd

       .InsertAfter (vbTab)

       .Collapse wdCollapseEnd

       .InsertAfter ("Page ")

       .Collapse wdCollapseEnd

       .Fields.Add Range:=rng, Type:=wdFieldPage, PreserveFormatting:=True

       .Collapse wdCollapseEnd

       .InsertAfter (" of ")

       .Collapse wdCollapseEnd

       .Fields.Add Range:=rng, Type:=wdFieldNumPages, PreserveFormatting:=True

       .Collapse wdCollapseEnd

   End With

   doc.Sections(1).Headers(wdHeaderFooterPrimary).Range.Fields.Update

End Sub

 

Sub CreateHeaderForwardsOkButAwkward()

   Dim doc As Word.Document, rng As Word.Range

   Set doc = ActiveDocument

   Set rng = doc.Sections(1).Headers(wdHeaderFooterPrimary).Range

   With rng

       .Fields.Add Range:=rng, Type:=wdFieldFileName, PreserveFormatting:=True

'       .Collapse wdCollapseEnd

       .InsertAfter (" ")

       .Collapse wdCollapseEnd

       .Fields.Add Range:=rng, Type:=wdFieldDate, Text:="\@ YYYY-MM-DD", PreserveFormatting:=True

   End With

   Set rng = doc.Sections(1).Headers(wdHeaderFooterPrimary).Range

   With rng

       .Collapse wdCollapseEnd

       .InsertAfter (vbTab)

       .Collapse wdCollapseEnd

       .InsertAfter (":-|")

       .Collapse wdCollapseEnd

       .InsertAfter (vbTab)

       .Collapse wdCollapseEnd

       .InsertAfter ("Page ")

       .Collapse wdCollapseEnd

       .Fields.Add Range:=rng, Type:=wdFieldPage, PreserveFormatting:=True

   End With

   Set rng = doc.Sections(1).Headers(wdHeaderFooterPrimary).Range

   With rng

       .Collapse wdCollapseEnd

       .InsertAfter (" of ")

       .Collapse wdCollapseEnd

       .Fields.Add Range:=rng, Type:=wdFieldNumPages, PreserveFormatting:=True

   End With

   Set rng = doc.Sections(1).Headers(wdHeaderFooterPrimary).Range

   With rng

       .Collapse wdCollapseEnd

   End With

   doc.Sections(1).Headers(wdHeaderFooterPrimary).Range.Fields.Update

End Sub

 

Sub CreateHeaderBackwards()

   Dim doc As Word.Document, rng As Word.Range

   Set doc = ActiveDocument

   Set rng = doc.Sections(1).Headers(wdHeaderFooterPrimary).Range

   With rng

       .Fields.Add Range:=rng, Type:=wdFieldNumPages, PreserveFormatting:=True

       .Collapse wdCollapseStart

       .InsertBefore (" of ")

       .Collapse wdCollapseStart

       .Fields.Add Range:=rng, Type:=wdFieldPage, PreserveFormatting:=True

       .Collapse wdCollapseStart

       .InsertBefore ("Page ")

       .Collapse wdCollapseStart

       .InsertBefore (vbTab)

       .Collapse wdCollapseStart

       .InsertBefore (":-)")

       .Collapse wdCollapseStart

       .InsertBefore (vbTab)

       .Collapse wdCollapseStart

       .Fields.Add Range:=rng, Type:=wdFieldDate, Text:="\@ YYYY-MM-DD", PreserveFormatting:=True

       .Collapse wdCollapseStart

       .InsertBefore (" ")

       .Collapse wdCollapseStart

       .Fields.Add Range:=rng, Type:=wdFieldFileName, PreserveFormatting:=True

       .Collapse wdCollapseStart

   End With

   doc.Sections(1).Headers(wdHeaderFooterPrimary).Range.Fields.Update

End Sub

Convert vector pictures to raster format

$
0
0

I'd like to rasterize large amount of vector pictures in Word 2010.

I made the following macro with which I have some problem.

In the first loop, it converts the shape to EMF, then in the second loop, drops an error at the CopyAsPicture line.

  1. Is EMF a shape too?
  2. how can I get word to skip the converted picture?

Dim oShp As Shape

If (ActiveDocument.Shapes.Count > 0) Then
    For Each oShp In ActiveDocument.Shapes
        With oShp
            MsgBox "Shape"
                .Select
                Selection.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
                Selection.Range.CopyAsPicture
                Selection.Range.Delete
                Selection.Range.PasteSpecial DataType:=wdPasteEnhancedMetafile
        End With
    Next
End If

Rich text field with background color that is not visible for printing

$
0
0

Hi, we're using Rich Text Fields quite extensively to create bindings between the document and our custom Word Task Pane app.

My question: I see that Rich Text Fields have a grey background by default, which is fine, however this background color is only visible when the user "hovers" over the field itself. If the user just reads the document he is not able to spot any differences between Rich Text Fields and regular text. We don't want to change the text formatting itself, but we would like to display that grey background constantly for all Rich Text Fields, however it should NOT be visible when printing. Is there any way to realize this?

Hyperlink in comment is not reported by Word object model

$
0
0

I believe this is a bug with Word.  I have verified with Word 2010 & 2013.  I did not test with any other version. 

If a hyperlink in a comment is the first thing in the comment, the Word object model does not report that there is a hyperlink in the comment.  If I modify the comment and add any text (including a space)before the link, the link will be reported by the object model.

Steps to reproduce: 

  1. in a document, go to Review Ribbon and select "New Comment"
  2. type in text, select text, and insert hyperlink (Ctrl+k), in address field add http://www.google.com
  3. Add a new macro that will loop through the comments and report if a hyperlink is found, see code below
  4. I also verified using VSTO the same behavior
    Dim doc As Document
    Set doc = ActiveDocument
    Dim link As Hyperlink
    Dim comment As comment
    For Each comment In doc.Comments
        On Error Resume Next
        If Not comment.Range Then
            For Each link In comment.Range.Hyperlinks
                MsgBox "Link found in comment"
            Next link
        End If
    Next comment


Byron


run tim error '5' invalid procedure call or argument visual basic

$
0
0

I have this error when switching between 2 specific excel document (developed tools), it doesn't actually seem to affect functionality because I can press 'end' and continue, it is however very annoying!! any clues??

Microsoft Word 2007 Macro to Outlook Contacts Field

$
0
0

The following hyperlink in Microsoft Word opens up a contact from Outlook. Is there an easy macro that goes to that contact, and adds to the work document, the words from a certain field in the contact. I have new fields in my contact form, and want the word document to show the words from some of those fields.

Here is the easy hyperlink to a contact in a subfolder of contacts: 
Outlook:Contacts/Subfolder Name/~Contact Name  Thanks very much.


Solution to Topaz validation problem

$
0
0

Topaz documentation states "Please note that form fields (such as drop down menus, radio buttons, etc.) are excluded from the binding process." Binding meaning the text is bound to the signature and validated.

Unfortunately I have to use these objects in forms I create for electronic medical records. I need some sort of simple code I can call every time one of them is selected. It needs to be relatively invisible but has to change the text enough to invalidate a document if one is selected after the patient has signed the document.

I played around with it but I'm too new to this and it's clunky and....well you can see.

Sub Fix_Checks()
'
' Fix_Checks Macro
'
'
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect
End If
Selection.GoTo What:=wdGoToBookmark, Name:="FirstCheck"
Selection.TypeText Text:="."
Selection.TypeBackspace
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub

Thank you for any help you might be able to offer.


Jamie Sloa

Why don't BuildingBlockTypes and BuildingBlockEntries reference the same building blocks?

$
0
0

I am missing something that I think should be almost obvious. The MSDN descriptions of Template.BuildingBlockTypes and Template.BuildingBlockEntries indicate to me that they are both a way of accessing the BuildingBlocks in the template. We use the BuildingBlockTypes interface to add QuickParts that we later extract to programmatically insert stuff. In the VSTO ThisDocument code, I need to remove some of the blocks that we previously inserted.  Since my current version of the code can't do the Add function, I manually added some QuickParts with the Category that we use in the code as my test base. When I use BuildingBlockTypes to get the QuickParts type and then check its Categories for the one I created, the Categories collection is empty!

var quickParts = template.BuildingBlockTypes.Item(Word.WdBuildingBlockTypes.wdTypeCustomQuickParts);
if (quickParts.Categories.Count > 0)
{
    // Never get here. . .
    var bldgBlocks = quickParts.Categories.Item(Const.MY_CATEGORY).BuildingBlocks;
    . . .
}

But when I look at BuildingBlockEntries, its only entries are the ones I manually created.  And their Type and Category are what I selected.

When I create a document from this template, the BuildingBlocks Organizer shows the entries I made, but when our code looks through BuildingBlockTypes for the building block to insert, it doesn't find it.  This tells me that the two collections are actually not views into the same space, but into different collections of building blocks.  So, now I'm confused.  What is the relationship between these and why do I see what I see?

Replicating the Word 2007 Content Control Toolkit in a Word Add-in

$
0
0

The Microsoft Word 2007 Content Control Toolkit parses the Open XML of a Word document and translates it into an object model. We require similar functionality from within a Word add-in. In particular, we need to access, both for reading and writing, the values of SharePoint properties associated with a document as shown in the image below.

How is it done?

Viewing all 4350 articles
Browse latest View live


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