Skip Ribbon Commands
Skip to main content - SharePoint User Group Schweiz/Liechtenstein

​Dies ist deine Anlaufstelle für Informationen, Treffen und Verzeichnisse rund um Microsoft SharePoint.

SharePoint 2010 - die Plattform für Zusammenarbeit in Gruppen, im Unternehmen, in Vereinen und im Web!

Der SharePoint BLOG:

Use INCLUDEPICTURE Field-Code in Microsoft Word for cool Letterheads and workaround some issues

In Microsoft Word you can do very cool stuff using Field Codes (Formulas). For example you could create a condition to show a Picture and with a few of them you’ll have a nice Picture Randomizer for your Document Header and Footer.

After you finished such an amazing Field Code you probably want to reuse it in other Documents but ran into some issues. Even in small documents Microsoft Word might become not responding, show totally or partially blank Pages or other strange display Issues. I’ll explain you what it causes and how to work around it.

The cool thing

We created a Word Template which looks similar to this simplified one:

Random Picture in Word Document Header Field Codes for Random Picture

That’s quite cool but requires no Macro! The Field Codes are like:
{ IF { =MOD({ PAGE }; 3 } = 0 { INCLUDEPICTURE “C:\\Letterhead\Blue.png” } }

The ugly thing

If you use Word 2010 and copy and paste these to another document it looks ok for the first moment. But as soon as people start to work with it, they might get these issues:

Scrolling Issue in Word 2010 Scrolling Issue in Word 2010

The document looks wrong when you scroll, zoom in/out or type. During that the CPU usage might be very high which indicates a performance issue. If you Press ALT + F9 to Toggle the Field Codes you’ll see there’s something wrong:

Replaced Field Codes after Copy and Paste Field Codes for Random Picture

Word 2010 just replaces the INCLUDEPICTURE Code with the actual picture which causes that issues.

The fix

To fix this issue you can either write the Formula again and again in Word 2010. Paste alternate didn’t work for us.

Or you can use Word 2013 where Copy and Paste works as expected. You can then save the File again as Word 2010 Document (check Maintain compatibility with previous versions of Word).


If you use Word 2013 (or maybe Word 2015) and open an older Word Document in Compatibility Mode, ensure to save it with Maintain compatibility with previous versions of Word checked. If you don’t you get a warning about “some minor layout changes are possible”. If you ignore that, you run into the same issue that INCLUCEPICTURE gets changed after saving!

Maintain compatibility with previous versions of Word some minor layout changes are possible

PS: if you check “Do not ask me again” you can’t undo this in any settings. It’s stored binarily in the Windows Registry at HKCU\Software\Microsoft\Office\15.0\Word. Just rename or remove that key.

Possible SharePoint Issues after Windows Updates on the Web Server

After Windows Updates ran on a Windows Server 2008 R2 with WSS3 SP3 we ran into a few issues caused by the Configuration Cache. This post shows you lessons learned and recommendations in case you have similar issues, especially if the Configuration Wizard crashes the entire SharePoint Farm.

Many Errors but no useful details

After about 80 Windows Updates there were the following errors:

  • showed HTTP 404
  • showed: InvalidOperationException: Operation is not valid due to the current state of the object (Stack Trace: OpenWebInternal, SetThreadCulture, ValidateDatabaseSchemaCompatibility, PreinitializeServer, PostResolveRequestCacheHandler, …)
  • SharePoint Central Administration worked normally

The detailed error message indicates to run the SharePoint Products Configuration wizard. So we did. But the Configuration Wizard failed with many errors related to the Database:

  • ExecuteNonQuery requires an open and available Connection. The connection’s current state is closed.
  • Database state cannot be changed while other users are using the database ‘SharePoint_Config_4829eeec-f431-4665-b10c-09ac21b35094′
    ALTER DATABASE statement failed

The SharePoint_Config DB stuck in Single User Mode and the SharePoint Farm was completely down. Central Administration showed “Cannot connect to the configuration database”, running the Configuration Wizard showed “Failed to detect if this server is joined to a server farm.” but all Windows Services were up and running. Also credentials IIS and the SQL Server were still correctly.

After a restore of the SharePoint_Config DB from a state before the Windows Update at lease Central Administration ran again. I ran psconfig -cmd upgrade -inplace b2b -wait -force which resulted in the same issue without any more details.

Don’t use the -force Parameter

I took a look at the documentation of psconfig and ran it without the -force attribute. I got the crucial message which was in no other Logfile before:

An update conflict has occurred, and you must re-try this action. The object SPConfigurationDatabase Name=SharePoint_Config_4829eeec-f431-4665-b10c-09ac21b35094 Parent=SPDatabaseServiceInstance Name=Microsoft##SSEE is being updated by NT AUTHORITY\SYSTEM, in the PSCONFIG process, on machine MYSERVERNAME. View the tracing log for more information about the conflict.


This leaded me to details about an update conflict has occurred, and you must re-try this. The Resolution to clear the Configuration Cache definitely fixed the issue even on WSS 3.

Here you’ll find more about what Is a Configuration Cache and Why Do I Care About It?

Lessons learned

  1. After Software Updates ran and the Configuration Wizard crashes the farm, restore the Farm Configuration DB might help
  2. Clear the configuration cache on servers you get curious errors about the SharePoint Config
  3. Run psconfig from the command line instead the GUI but don’t use the force attribute


Detailed Error Message of the SharePoint Content Application:

[InvalidOperationException: Operation is not valid due to the current state of the object.]

Microsoft.SharePoint.Library.SPRequestInternalClass.OpenWebInternal(String bstrUrl, Guid& pguidID, String& pbstrRequestAccessEmail, UInt32& pwebVersion, String& pbstrServerRelativeUrl, UInt32& pnLanguage, UInt32& pnLocale, String& pbstrDefaultTheme, String& pbstrDefaultThemeCSSUrl, String& pbstrAlternateCSSUrl, String& pbstrCustomizedCssFileList, String& pbstrCustomJSUrl, String& pbstrAlternateHeaderUrl, String& pbstrMasterUrl, String& pbstrCustomMasterUrl, String& pbstrSiteLogoUrl, String& pbstrSiteLogoDescription, Object& pvarUser, Boolean& pvarIsAuditor, Int32& plSiteFlags) +0
Microsoft.SharePoint.Library.SPRequest.OpenWebInternal(String bstrUrl, Guid& pguidID, String& pbstrRequestAccessEmail, UInt32& pwebVersion, String& pbstrServerRelativeUrl, UInt32& pnLanguage, UInt32& pnLocale, String& pbstrDefaultTheme, String& pbstrDefaultThemeCSSUrl, String& pbstrAlternateCSSUrl, String& pbstrCustomizedCssFileList, String& pbstrCustomJSUrl, String& pbstrAlternateHeaderUrl, String& pbstrMasterUrl, String& pbstrCustomMasterUrl, String& pbstrSiteLogoUrl, String& pbstrSiteLogoDescription, Object& pvarUser, Boolean& pvarIsAuditor, Int32& plSiteFlags) +429
Microsoft.SharePoint.SPWeb.InitWebPublic() +1091
Microsoft.SharePoint.SPWeb.get_Locale() +142
Microsoft.SharePoint.WebPartPages.Utility.SetThreadCulture(SPWeb spWeb, Boolean force) +95
Microsoft.SharePoint.WebPartPages.Utility.SetThreadCulture(SPWeb spWeb) +58
Microsoft.SharePoint.CoreResource.GetString(ResourceGroup rg, String name, Object[] values) +1081
Microsoft.SharePoint.SPResource.GetString(String name, Object[] values) +53
Microsoft.SharePoint.Administration.SPContentDatabase.ValidateDatabaseSchemaCompatibility() +534
Microsoft.SharePoint.SPSite.PreinitializeServer(SPRequest request) +99
Microsoft.SharePoint.SPWeb.InitializeSPRequest() +548
Microsoft.SharePoint.SPWeb.EnsureSPRequest() +75
Microsoft.SharePoint.SPWeb.get_Request() +74
Microsoft.SharePoint.WebControls.SPControl.SPWebEnsureSPControl(HttpContext context) +613
Microsoft.SharePoint.WebControls.SPControl.GetContextWeb(HttpContext context) +41
Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.PostResolveRequestCacheHandler(Object oSender, EventArgs ea) +595
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171

SharePoint 2013 PDF in neuem Fenster öffnen

Oft werde ich gefragt, wieso Office-Dateien (Word, Excel, PowerPoint) im jeweiligen Office-Programm öffnen aber PDFs im aktuellen Browser-Fenster/Register öffnen. Leider kann das auch heute noch nicht einfach konfiguriert werden.

Je nach Browser und PDF-Reader kann das vielleicht auf dem Client konfiguriert werden, aber spätestens seit Firefox und Chrome mit eigenen PDF-Viewern einen neue Vielfalt möglicher Konfigurationen hervorgebracht haben, muss dies im SharePoint gelöst werden.

Es gibt im Internet einige Beispiele um dieses Problem per JavaScript zu lösen (siehe unten), jedoch funktioniert keines davon mit neuen AJAX-Features in SharePoint 2013 (Minimal Download Strategy und Client Side Rendering).

In diesem Beitrag zeige ich, wie es in SharePoint 2013 und Office 365 mit JavaScript gelöst werden kann.

Einfachste Lösung

Der einfachste Weg ist natürlich mit jQuery. jQuery binde ich in der Regel über die Master Page ein und platziere Globale JavaScripts in /SiteAssets/Scripts/Global.js. Für SharePoint 2013 könnte eine einfache Lösung folgendermassen aussehen:

$(document).ready(function () {
  function updatePdfLinksTarget() {
    $("a[href*='.pdf']").attr('target', '_blank').prop("onclick", null).attr("onmousedown", null);
  setInterval(updatePdfLinksTarget, 1000);

Die Lösung funktioniert mit sämtlichen PDF-Links aber ist nicht besonders effizient. Dieses JavaScript durchläuft jede Sekunde das gesamte DOM und modifiziert dabei immer alle Links mit .pdf im Pfadende. Somit müssen nicht alle möglichen Seiten-/DOM-Modifikationen von der Minimal Download Strategy (MDS) und Client-Side Rendering (CSR) speziell gehandelt werden.

Bessere Lösung

Eine effizientere Lösung ist, die PDF-Links auf der Seite nur zu suchen und modifizieren, wenn per MDS die Content Area aktualisiert wurde oder wenn per Client-Side Rendering sortiert, gefiltert oder die Seite gewechselt wurde (Paging). Das folgende JavaScript macht genau das:

function initUpdatePdfLinksTarget() {
  if (typeof SPClientTemplates != "undefined" && SPClientTemplates.TemplateManager)
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides({ OnPostRender: [updatePdfLinksTarget] });
function updatePdfLinksTarget() {
  $("a[href*='.pdf']").attr('target', '_blank').prop("onclick", null).attr("onmousedown", null);
  return false;
ExecuteOrDelayUntilScriptLoaded(function () {
  if (typeof asyncDeltaManager != "undefined")
}, "start.js");


ExecuteOrDelayUntilScriptLoaded ersetzt den $(document).ready Event und wird einmalig aufgerufen. Falls MDS aktiviert ist (asyncDeltaManager vorhanden), wird initUpdatePdfLinksTarget bei jedem end-Request ausgeführt, also immer wenn die Content Area geändert hat. Letzteres führt dann updatePdfLinksTarget aus und registriert diese Funktion beim Client Side Rendering, also wenn sortiert, gefiltert oder die Seite gewechselt wurde.

Die Problematik mit jQuery(document).ready in SharePoint ist u.a. hier beschrieben:

Alternativer Workaround

Wer ganz auf Code verzichten will, kann auch die Anwender einfach schulen, PDFs in “in neuem Tab” zu öffnen per Kontext-Menü oder Control & Click.

PDF in neuem Tab öffnen per Kontext-Menü

PDF in neuem Tab öffnen per Kontext-Menü

Wie es in SharePoint 2010 gelöst werden kann

„Check Out & Open“ Dialog beim Öffnen von PDFs im SharePoint deaktivieren

Beim Öffnen von PDF Dateien aus SharePoint erscheint ein Dialog, ob das Dokument ausgecheckt werden soll (seit Adobe Reader Version 10). Meistens werden PDFs nur im Lesemodus benötigt, deshalb ist es insbesondere störend, dass „Check Out & Open“ der Standard-Button ist statt „Open“.

Seit Abode Reader Version 10.1 kann diese Funktion in der Windows Registry deaktiviert werden.


  1. Adobe Reader schliessen
  2. Windows Registry öffnen (als Administrator)
  3. Navigieren zu: HKLM\SOFTWARE\Policies\Adobe\Adobe Reader\10\FeatureLockDown (ggf. andere Versionsnummer)
  4. Neuen Key/Ordner erstellen mit Namen cSharePoint.
  5. Neuen DWORD Wert erstellen mit Namen bDisableSharePointFeatures und Wert 1

Der Registry Eintrag kann auch über GPSo auf alle Workstations verteilt werden:

Weiterführende Infos


 SPUGS Kalender

There are no items to show in this view of the "Agenda" list.

 SPUGSch - Twitter Search

Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Microsoft SharePoint Foundation-compatible HTML editor such as Microsoft SharePoint Designer. If the problem persists, contact your Web server administrator.

Correlation ID:9e30331b-0cc0-4d03-9ad8-60ac89fd36e4