Showing posts with label Word. Show all posts
Showing posts with label Word. Show all posts

Friday, 8 January 2010

Edit Office Document from SharePoint in IE8 64 bit version

Have you ever tried to open a Word document from a SharePoint 2007 document library using Internet Explorer 8 64 bit edition? Today I tried, because I am running a 64 bit Windows 7 edition.
Guess what, next message was shown:


So I tried also to open a Word document from a SharePoint 2010 document library in IE8 x64. Of course, it doesn't work either. Only the message was a bit different:


Oh, by the way, I am using Office 2007 SP2. I didn't try it with Office 2010 (not installed yet). Maybe that will work? I guess not, but I let you know.
Thanks Microsoft! :(

Update:

I read on technet that the IE8 64 is a so called Level 2 brower. According to Microsoft, Web browser support is divided into two levels: level 1 and level 2. Although administrative tasks on SharePoint sites are optimized for level 1 browsers, SharePoint Server 2010 also provides support for other browsers that are frequently used. To ensure that you have complete access to all functionality, we recommend that you use a level 1 browser for administrative tasks.

So it seems that editing a Word document from SharePoint is administrative task. In SharePoint it is called 'contribution'... do you follow it?

Read more at Microsoft Technet:
http://technet.microsoft.com/en-us/library/cc263526%28office.14%29.aspx

Tuesday, 22 September 2009

Update all fields in Word, including headers and footers (Edit)

At 11th November last year, I post a piece of code to update all fields in a Word document. Some people respond that it didn't work. Well, I tried, and it seems that's true.
Today, I rewrote a new piece of code I found, and that seems to work fine. I created an extension method for the Word.Document object that does the trick.

_
Sub UpdateAllFiels(ByVal doc As Word.Document)

Dim section As Word.Section
Dim myRange As Word.Range
Dim myHF As Word.HeaderFooter

doc.Fields.Update()

For Each section In doc.Sections

For Each myHF In section.Headers
myRange = myHF.Range

For Each aField In myRange.Fields
If aField.Type = Word.WdFieldType.wdFieldDocProperty Then
aField.Update()
End If
Next aField

Next myHF

For Each myHF In section.Footers
myRange = myHF.Range

For Each aField In myRange.Fields
If aField.Type = Word.WdFieldType.wdFieldDocProperty Then
aField.Update()
End If
Next aField

Next myHF

Next section

End Sub

So, now I am able to update all fields easily in my document. In my Word Add-on, I created a own ribbon tab, I placed a button on it, which does the following:

Globals.ThisAddIn.Application.ActiveDocument.UpdateAllFiels()

Note: Extension methods is supported on .NET framework 3.5 or higher

Edit: A little fix: 'doc.Fields.Update()' added to the code. This is the regular Word Update All Fields function (so without doing Headers and Footers).

Thursday, 12 March 2009

Why you don't want paste directly from Word to Blogger

Haha, today I thought to do something smart. I had a (short) line of text in my Word 2007 document (selected part),



and I was writing my previous post (Restore My Sites from different domain). So, just the copy - paste (from Word 2007 to Blogspot). Oops, I didn't went well (format messed up a bit :). So, I thought, well lets fix it at the 'Edit Html' tab. Woops, what's that? I saw a huge amount of code, just to show my short line of text. It places over more than 2,600 words containing almost 26,000!! characters. I reformatted this piece of code, just to share my experience with you.
I put it here:

<?xml version="1.0" encoding="utf-8" ?>
<ol>
<li>
<meta equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="ProgId" content="Word.Document">
<meta name="Generator" content="Microsoft Word 12">
<meta name="Originator" content="Microsoft Word 12">
<link rel="File-List"
href="file:///C:%5CDOCUME%7E1%5CROBVAN%7E1.000%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml">
<link rel="themeData"
href="file:///C:%5CDOCUME%7E1%5CROBVAN%7E1.000%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx">
<link rel="colorSchemeMapping"
href="file:///C:%5CDOCUME%7E1%5CROBVAN%7E1.000%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml">
<!--[if gte mso 9]>
<xml>
<w:worddocument>
<w:view>
Normal
</w:View>
<w:zoom>
0
</w:Zoom>
<w:trackmoves/>
<w:trackformatting/>
<w:punctuationkerning/>
<w:validateagainstschemas/>
<w:saveifxmlinvalid>
false
</w:SaveIfXMLInvalid>
<w:ignoremixedcontent>
false
</w:IgnoreMixedContent>
<w:alwaysshowplaceholdertext>
false
</w:AlwaysShowPlaceholderText>
<w:donotpromoteqf/>
<w:lidthemeother>
EN-US
</w:LidThemeOther>
<w:lidthemeasian>
X-NONE
</w:LidThemeAsian>
<w:lidthemecomplexscript>
X-NONE
</w:LidThemeComplexScript>
<w:compatibility>
<w:breakwrappedtables/>
<w:snaptogridincell/>
<w:wraptextwithpunct/>
<w:useasianbreakrules/>
<w:dontgrowautofit/>
<w:splitpgbreakandparamark/>
<w:dontvertaligncellwithsp/>
<w:dontbreakconstrainedforcedtables/>
<w:dontvertalignintxbx/>
<w:word11kerningpairs/>
<w:cachedcolbalance/>
</w:Compatibility>
<w:browserlevel>
MicrosoftInternetExplorer4
</w:BrowserLevel>
<m:mathpr>
<m:mathfont val="Cambria Math">
<m:brkbin val="before">
<m:brkbinsub val="--">
<m:smallfrac val="off">
<m:dispdef/>
<m:lmargin val="0">
<m:rmargin val="0">
<m:defjc val="centerGroup">
<m:wrapindent val="1440">
<m:intlim val="subSup">
<m:narylim val="undOvr">
</m:mathPr>
</w:WordDocument>
</xml>
<![endif]-->
<!--[if gte mso 9]>
<xml>
<w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267">
<w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal">
<w:lsdexception locked="false" priority="9" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1">
<w:lsdexception locked="false" priority="9" qformat="true" name="heading 2">
<w:lsdexception locked="false" priority="9" qformat="true" name="heading 3">
<w:lsdexception locked="false" priority="9" qformat="true" name="heading 4">
<w:lsdexception locked="false" priority="9" qformat="true" name="heading 5">
<w:lsdexception locked="false" priority="9" qformat="true" name="heading 6">
<w:lsdexception locked="false" priority="9" qformat="true" name="heading 7">
<w:lsdexception locked="false" priority="9" qformat="true" name="heading 8">
<w:lsdexception locked="false" priority="9" qformat="true" name="heading 9">
<w:lsdexception locked="false" priority="39" name="toc 1">
<w:lsdexception locked="false" priority="39" name="toc 2">
<w:lsdexception locked="false" priority="39" name="toc 3">
<w:lsdexception locked="false" priority="39" name="toc 4">
<w:lsdexception locked="false" priority="39" name="toc 5">
<w:lsdexception locked="false" priority="39" name="toc 6">
<w:lsdexception locked="false" priority="39" name="toc 7">
<w:lsdexception locked="false" priority="39" name="toc 8">
<w:lsdexception locked="false" priority="39" name="toc 9">
<w:lsdexception locked="false" priority="35" qformat="true" name="caption">
<w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title">
<w:lsdexception locked="false" priority="1" name="Default Paragraph Font">
<w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle">
<w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong">
<w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis">
<w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid">
<w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text">
<w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing">
<w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading">
<w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List">
<w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid">
<w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1">
<w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2">
<w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1">
<w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2">
<w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1">
<w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2">
<w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3">
<w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List">
<w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading">
<w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List">
<w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid">
<w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1">
<w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1">
<w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1">
<w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1">
<w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1">
<w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1">
<w:lsdexception locked="false" unhidewhenused="false" name="Revision">
<w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph">
<w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote">
<w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote">
<w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1">
<w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1">
<w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1">
<w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1">
<w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1">
<w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1">
<w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1">
<w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1">
<w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2">
<w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2">
<w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2">
<w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2">
<w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2">
<w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2">
<w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2">
<w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2">
<w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2">
<w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2">
<w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2">
<w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2">
<w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2">
<w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2">
<w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3">
<w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3">
<w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3">
<w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3">
<w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3">
<w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3">
<w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3">
<w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3">
<w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3">
<w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3">
<w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3">
<w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3">
<w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3">
<w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3">
<w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4">
<w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4">
<w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4">
<w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4">
<w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4">
<w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4">
<w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4">
<w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4">
<w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4">
<w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4">
<w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4">
<w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4">
<w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4">
<w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4">
<w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5">
<w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5">
<w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5">
<w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5">
<w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5">
<w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5">
<w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5">
<w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5">
<w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5">
<w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5">
<w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5">
<w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5">
<w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5">
<w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5">
<w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6">
<w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6">
<w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6">
<w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6">
<w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6">
<w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6">
<w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6">
<w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6">
<w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6">
<w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6">
<w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6">
<w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6">
<w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6">
<w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6">
<w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis">
<w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis">
<w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference">
<w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference">
<w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title">
<w:lsdexception locked="false" priority="37" name="Bibliography">
<w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading">
</w:LatentStyles>
</xml>
<![endif]-->
<style>
<!-- /* Font Definitions */
@font-face {
font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;
mso-font-charset:0;
mso-generic-font-family:roman;
mso-font-pitch:variable;
mso-font-signature:-1610611985 1107304683 0 0 159 0;
}
@font-face {
font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:-1593833729 1073750107 16 0 415 0;
}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal {
mso-style-unhide:no;
mso-style-qformat:yes;
mso-style-parent:"";
margin-top:0cm;
margin-right:0cm;
margin-bottom:6.0pt;
margin-left:53.85pt;
text-align:justify;
mso-pagination:widow-orphan;
tab-stops:53.85pt;
font-size:9.0pt;
font-family:"Verdana","sans-serif";
mso-fareast-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";
mso-ansi-language:NL;
}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {
mso-style-update:auto;
mso-style-priority:34;
mso-style-unhide:no;
mso-style-qformat:yes;
margin-top:0cm;
margin-right:0cm;
margin-bottom:6.0pt;
margin-left:36.0pt;
mso-add-space:auto;
text-align:justify;
mso-pagination:widow-orphan;
tab-stops:53.85pt;
font-size:9.0pt;
font-family:"Verdana","sans-serif";
mso-fareast-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";
mso-ansi-language:NL;
}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst {
mso-style-update:auto;
mso-style-priority:34;
mso-style-unhide:no;
mso-style-qformat:yes;
mso-style-type:export-only;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
margin-bottom:.0001pt;
mso-add-space:auto;
text-align:justify;
mso-pagination:widow-orphan;
tab-stops:53.85pt;
font-size:9.0pt;
font-family:"Verdana","sans-serif";
mso-fareast-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";
mso-ansi-language:NL;
}
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle {
mso-style-update:auto;
mso-style-priority:34;
mso-style-unhide:no;
mso-style-qformat:yes;
mso-style-type:export-only;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
margin-bottom:.0001pt;
mso-add-space:auto;
text-align:justify;
mso-pagination:widow-orphan;
tab-stops:53.85pt;
font-size:9.0pt;
font-family:"Verdana","sans-serif";
mso-fareast-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";
mso-ansi-language:NL;
}
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast {
mso-style-update:auto;
mso-style-priority:34;
mso-style-unhide:no;
mso-style-qformat:yes;
mso-style-type:export-only;
margin-top:0cm;
margin-right:0cm;
margin-bottom:6.0pt;
margin-left:36.0pt;
mso-add-space:auto;
text-align:justify;
mso-pagination:widow-orphan;
tab-stops:53.85pt;
font-size:9.0pt;
font-family:"Verdana","sans-serif";
mso-fareast-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";
mso-ansi-language:NL;
}
.MsoChpDefault {
mso-style-type:export-only;
mso-default-props:yes;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;
mso-ansi-language:NL;
}
.MsoPapDefault {
mso-style-type:export-only;
margin-bottom:10.0pt;
line-height:115%;
}
@page Section1 {
size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;
mso-header-margin:36.0pt;
mso-footer-margin:36.0pt;
mso-paper-source:0;
}
div.Section1 {
page:Section1;
}
/* List Definitions */ @list l0 {
mso-list-id:1515269166;
mso-list-type:hybrid;
mso-list-template-ids:580178114 -1823804710 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;
}
@list l0:level1 {
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:71.85pt;
text-indent:-18.0pt;
}
@list l0:level2 {
mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:107.85pt;
text-indent:-18.0pt;
}
ol {
margin-bottom:0cm;
}
ul {
margin-bottom:0cm;
} -->
</style>
<!--[if gte mso 10]> <style> /* Style Definitions */
table.MsoNormalTable {
mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-ansi-language:NL;
} </style> <![endif]-->
<p class="MsoListParagraph" style="margin-left: 71.85pt; text-indent: -18pt;">
<!--[if !supportLists]-->
<span style="">
<span style="">
1.<span ;
font-style: normal; font-variant: normal; font-weight: normal;
font-size: 7pt; line-height: normal; font-size-adjust:
none; font-stretch: normal;"> </span>
</span>
</span>
<!--[endif]-->
<span style="">
First of all, let the user create a My Site, in my example there will
be a site called: http://intranet/personal/brian_cox<o:p></o:p>
</span>
</p>
</li>
</ol>

So, just find the sentence: First of all, let the user create a My Site, in my example there will be a site called: http://intranet/personal/brian_cox :)

Tuesday, 11 November 2008

Update all fields in Word, including headers and footers

The regular 'update all fields' method in Word does not update used fields in the headers and footers. I searched on the internet to find a proper method and I found some code, but almost every time, they didn't really do what they are supposed to do. I found one piece of code which will update the fields in headers and footers. I combined it with the normal update procedure and now I have one method to update all field:



Public Sub UpdateAllFields()
Dim currentDocument As Document _
= Globals.DnmOfficeAddIn.Application.ActiveDocument
If currentDocument IsNot Nothing Then
Dim aStory As Range
Dim NumberOfFields As Integer = 0

Cursor.Current = Cursors.WaitCursor
Try
For Each aStory In currentDocument.StoryRanges
NumberOfFields += aStory.Fields.Count
Next

If NumberOfFields > 0 Then
'Update all available fields in the document
For Each aStory In currentDocument.StoryRanges
aStory.Fields.Update()
Next

Dim section As Section
Dim DocumentRange As Range
Dim DocumentHeaderFooter As HeaderFooter

' Loop through the header/footer for each section.
' If this isn't done specifically, Word seems to
' skip the header/footer of sections after section 1.
For Each section In currentDocument.Sections
For Each DocumentHeaderFooter In section.Headers

DocumentRange = DocumentHeaderFooter.Range
For Each aField As Field In DocumentRange.Fields

If aField.Type = WdFieldType.wdFieldDocProperty Then
aField.Update()
End If

Next aField

Next DocumentHeaderFooter

For Each DocumentHeaderFooter In section.Footers

DocumentRange = DocumentHeaderFooter.Range
For Each aField As Field In DocumentRange.Fields

If aField.Type = WdFieldType.wdFieldDocProperty Then
aField.Update()
End If

Next aField

Next DocumentHeaderFooter

Next section
Else
MessageBox.Show( _
"This document does not contain any updatable fields.", _
"No fields", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
End If
Finally
Cursor.Current = Cursors.Default
End Try
End If
End Sub

Good luck!


(By the way, I used this code in a Office 2007 environment)



EDIT: See my latest blog for a working version: http://blog.vanmeeuwen-online.nl/2009/09/update-all-fields-in-word-including.html