Showing posts with label Microsoft Office 2007. Show all posts
Showing posts with label Microsoft Office 2007. Show all posts

4/05/2011

SharePoint: File Types Supported by Office Web Apps

 

I’ve had a few questions about the files and extensions supported by SharePoint’s Office Web Apps.

 

Quick Notes:

Only Office 2007 and later formats supported: docx, xlsx, pptx, etc.

Cannot create new documents, so dotx, etc not supported

 

Details:

Rather than copy and paste someone else's work, I’ll just give you the link!

http://support.microsoft.com/kb/2028380

 

For features that only work in the full client applications see:

http://technet.microsoft.com/en-us/library/ff431682.aspx

 

.

1/12/2011

Interesting SharePoint Controls

Recently while reviewing a SharePoint 2010 developer class it occurred to me that the class made no mention of any of the SharePoint controls. So as I get the time I’ll write a description and find a sample or two of use for the more interesting controls. I’ll use this page as a “table of contents” for these articles.

 

These controls are all part of the Microsoft.SharePoint.WebControls namespace.

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.aspx 

 

Here’s the first two:

 

.

12/15/2010

SharePoint: How to get the SharePoint version from JavaScript

 

Update: I found a JavaScript function that returns the version number. Content below has been updated.

 

Simple question:

I’m writing some JavaScript that will run almost identically in SharePoint 2007 and SharePoint 2010. How can I write an IF statement to test the version?

 

So far I have found no simple answer, but I have found a few that work. Each has an “if” or a “risk”, so pick one that works for you.  If you know a better way, please post a comment below.  I propose three methods:

  • Method 1: Check the “_fV4UI” variable
  • Method 2: Check for an element with “V4” or “s4” in its ID or style
  • Method 3: Get the EXACT (almost) version number
  • Method 4: Call a SharePoint 2010 ECMAScript Class Library Object Method

 

SharePoint Versions: (that I’m interested in…)

  • 2007, also called 3.0 or V3, also called version 12
  • 2010, also called 4.0 or V4, also called version 14
  • and one day 201x, called 5.0 or V5? also called version 15?
  • would also love to get WSS vs MOSS and Foundation vs Server

It would be nice if:

  • something in the page had the version number?  (14.xxx)  (I can’t find it)
  • there’s a JavaScript function in one of the core libraries somewhere? (I can’t find one)  (Update: actually there is in 2010)

Solution requirements:

  • Must be available in all site pages, and ideally in all application pages
  • Must be in all templates
  • Must still be there after major master page branding surgery
  • Should still be useful

A few quick ideas:

  • Look for one of the many controls with a tag with “V4” embedded or one of the CSS classes with “V4” embedded. (Risk? Minimal, but site branders who have really hacked the master page or the styles could mess this up.)
  • Look for a unique JavaScript variable (see _fV4UI below). (Risk? Minimal, but a web search for “_fV4UI” finds a number of articles that mention deleting this from the master pages.)

Method 1: Check the “_fV4UI” variable

 

SharePoint 2010 pages have a JavaScript variable named “_fV4UI” that indicates if the page is using the “V4” navigation (Ribbon).  After an upgrade from SP 2007 this variable will be set to “false”. When the user interface is upgraded to the ribbon this will be set to “true”.

So:

  • if _fV4UI does not exist we probably have SP 2007
  • if _fV4UI does exist we probably have SP 2010
  • will there be a _fV5UI in the next version?  (can only wait and see)

The code:

<script type="text/javascript">
  if ( typeof _fV4UI == "undefined" ) 
  {
    // 2007 code here
  }
  else
  {
    // 2010 code here
  }  
</script>

Pros:

  • Probably the easiest test to do
  • Very simple code
    Can even be reduced to one line:

         var SPversion = (typeof _fV4UI == "undefined") ? "12" : "14";

Cons:

  • Your code must be placed after where SharePoint initializes this variable. Be aware that a number of blog articles mention removing the first instance listed below.

    This is where I found it in a Team Site:
    • Line 13 in the <HEAD> section  (this is the only one you will see in the master page)
    • Line 100 in the <BODY> section  (auto generated by a control)
    • Line 1033 near the end of the page  (auto generated by a control)

 

Method 2: Check for an element with “V4” or “s4” in its ID or style

 

The challenge here is, which one? You will need to pick an element that will reliably exist in all branded and unbranded pages.  Just about everything in the master page is up for grabs when custom branded. (Yes, I have seen branded sites without a title, Quick Launch, Tabs, Search, View All Files and Recycle Bin!) 

The control you pick needs to be towards the top of the page and most likely left behind in a branded master page. So let’s pick one… (let me know if there is a better one)  Both SP 2007 and SP 2010 have a hidden <SPAN> or <DIV> named TurnOnAccessibility. In 2010 this DIV has a style named “s4-notdlg”, which SP 2007 will never have, so let’s test for that:

The code:

<script type="text/javascript">
  if ( document.getElementById("TurnOnAccessibility").className == ""  ) 
  {
    // 2007 code here
  }
  else
  {
    // 2010 code here
  }  
</script>

Pros:

  • Easy to test
  • The tag we are testing is at the very top of the page

Cons:

  • This will probably be one of the first things a brander will remove (mostly as they have no idea what it is for)

What is TurnOnAccessibility for? The dropdown menus in SharePoint, such as the Welcome menu or Site Actions, are dynamically generated and somewhat meaningless to a user with vision problems who is using a screen reading program. When “more accessible mode” is enabled, clicking what usually is a dropdown menu will open a popup window with all of the menu options listed.

 

Method 3: Getting the EXACT (almost) version number

 

Now this is what I really want, and it is sent by SharePoint for every page request, but as part of the HTTP Header.  But… most of what’s in that header is not available to JavaScript.

Here’s what’s sent from SharePoint 2010 in the header:

image

Is that version number right?
    14.0.0.4762  reported in the header
    14.0.4763.1000 reported in Central Admin for SharePoint
    14.0.4763.1000 also reported in CA as the database schema version

This number is what is found in IIS under HTTP Response Headers.

image

Anybody know why it does not match any other SP 2010 version number? 

 

Ok, the number is not the correct version, but it is close!

 

SharePoint 2007 reports:

image

At least this is the correct version!

 

So if JavaScript cannot read this header value, how do we get it? Depends on which browser you are using, so I’m using a routine from an MSDN article to deal with the browser version.

 

The code:

<script type="text/javascript">

  /*
    The following copied from:
    http://msdn.microsoft.com/en-us/library/ms537505(v=vs.85).aspx
  */
  var xmlHttp = null;
  if (window.XMLHttpRequest) {
    // If IE7, Mozilla, Safari, and so on: Use native object.
    xmlHttp = new XMLHttpRequest();
  }
  else
  {
    if (window.ActiveXObject) {
       // ...otherwise, use the ActiveX control for IE5.x and IE6.
       xmlHttp = new ActiveXObject('MSXML2.XMLHTTP.3.0');
    }
  }
  /*
    end copy
  */

  xmlHttp.open('HEAD', location.href, false);
  xmlHttp.send();
  var headers =  xmlHttp.getAllResponseHeaders();
  var SPVersion = xmlHttp.getResponseHeader("MicrosoftSharePointTeamServices");

  if ( SPVersion.substring(0,2) == "12"  ) 
  {
    // 2007 code here
  }
  else
  {
    // 2010 code here
  }  

</script>

Note: The XMLHttpRequest call is usually setup with an asynchronous callback as the URL called is usually not the same URL that contains the calling JavaScript.  The example above does not seem to need this as it appears the header is read from the current copy of the page (“location.href”). Test this in your environment!

 

It would be a good idea to wrap this code as a function and add this to a custom JavaScript library that you would load in the master page. You can then call it as needed from other routines.

function getSharePointMajorVersion()
{
 // The following copied from: http://msdn.microsoft.com/en-us/library/ms537505(v=vs.85).aspx
  var xmlHttp = null;
  if (window.XMLHttpRequest) {
    // If IE7, Mozilla, Safari, and so on: Use native object.
    xmlHttp = new XMLHttpRequest();
  }
  else  {
    if (window.ActiveXObject) {
       // ...otherwise, use the ActiveX control for IE5.x and IE6.
       xmlHttp = new ActiveXObject('MSXML2.XMLHTTP.3.0');
    }
  }
  //  end copy

  xmlHttp.open('HEAD', location.href, false);
  xmlHttp.send();
  var SPVersion = xmlHttp.getResponseHeader("MicrosoftSharePointTeamServices");

  return  SPVersion.substring(0,2) 
}  

 

Pros:

  • Gets the version number, so should also work with the “next version” of SharePoint (15?)
  • Should work regardless of “branded” master page changes
  • Works with the browsers I test with: IE6, IE7, IE8 and FireFox 3.5.10

Cons:

  • A lot of code for a just to see if we are in 2007 or 2010
  • The version number returned is stored in the IIS settings and could get changed independent of SharePoint (I don’t know if service packs update this)
  • The SharePoint 2010 version returned is not 100% correct (but the major version “14” is correct)

 

Method 4: Call a SharePoint 2010 ECMAScript Class Library Object Method

SharePoint 2010 supports a JavaScript client object model that can access lists, libraries and other content. Once of the classes is called SP.ClientSchemaVersions and it has a property called currentVersion that returns a version number. This number is not the version of SharePoint itself, but appears to be the version of the library as it returns “14.0.0.0” only.

So:

  • if “SP.ClientSchemaVersions.currentVersion”does not exist we probably have SP 2007
  • if “SP.ClientSchemaVersions.currentVersion” does exist and starts with “14” then we probably have SharePoint 2010
  • And… if we are lucky “SP.ClientSchemaVersions.currentVersion” will return “15.something” for the next version.

The Code:

<script type="text/javascript">

function SampleFunction()
{
  var SPversion = "12"; 

  try { SPversion = SP.ClientSchemaVersions.currentVersion.substring(0,2) } 
  catch (e) {}

  if (SPversion == "12")
  {
      // 2007 code here
  }
  else
  {
      // 2010 (and later) code here
  }
}

ExecuteOrDelayUntilScriptLoaded( SampleFunction, "sp.js" );

</script>

 

Pros:

  • Gets the version number, so should also work with the “next version” of SharePoint (15?)
  • Should work regardless of “branded” master page changes
  • Works with the browsers I test with: IE6, IE7, IE8 and FireFox 3.5.10

Cons:

  • A lot of code for a just to see if we are in 2007 or 2010
  • The version number returned is for the script library, not SharePoint (but that should be OK)
  • Our code can only be run after the page is fully loaded and the “sp.js” library has been loaded (that’s why we need the ExecuteOrDelayUntilScriptLoaded call)
  • Our code must be wrapped up in a JavaScript function  (SampleFunction in the example above)

 

My Preference?

Right now it is Method 1, Check the “_fV4UI” variable.  It’s simple and light weight. But just remember the variable initialization could get deleted by someone working on the master page.

 

 

 

 Know a better way?  Post a comment below!

 

.

2/02/2010

Silly Word 2007 Tricks - Lorem ipsum!

 

Open a new document in Word 2007,

 

type     =lorem(3,8)     and press enter...    Lorem ipsum!

 

move to a blank line and type    =rand(10,5)    and press enter...     you are now a tech writer!

 

again...     =rand.old(5,5)  and press enter…    and you are a typewriter tester!

 

 

Now get back to work............

 

 

and when you have some free time… click here…  http://en.wikipedia.org/wiki/Lorem_ipsum

2/26/2008

SharePoint: Excel 2003 Import and Outlook problems (Method 'Post' of object 'IOWSPostData' failed)

 

Updated… New version of Office, same old problem!  If you get the IOWSPostData error the same fix for Office 2007 will also work for Office 2010.

Updated again 2/24/13… This time for SharePoint 2013 and Office 2010.

One of my VPC images for SharePoint is acting up. It has MOSS 2007 and Office 2003. The problems are: Import from Excel fails and Connect To Outlook fails. Another VPC created from the same original setup is fine. The only thing really different with this VPC is that it has SharePoint Designer installed.

Errors from Excel: "object doesn't support this property or method"
Errors from Outlook (not consistent) : "Method 'Post' of object 'IOWSPostData' failed"

What appears to have happened is that SharePoint Designer is an Office 2007 product, it installs a bunch of Office 12 files and must be updating default paths or registry entries to point to Office 12 instead of Office 11. For the Excel issue I think it is loading the Office 12 DLL and calling from an Office 11 Excel macro file. I have not found a workaround yet for the Outlook problem. It works sometime and not others. My research so far (thanks to all of the bloggers out there!) has found at least a fix for the Excel Import problem. This requires an edit to the macro used by SharePoint to perform the import.

  • Open the macro file in Excel (Excel 2003 is ok, or at least worked for me)
      C:\Program Files\Microsoft Office 2007\Office12\1033\EXPTOOWS.XLA
    For Office 2010 find the file here:
      C:\Program Files\Microsoft Office\Office14\1033\EXPTOOWS.XLA
    or
      C:\Program Files (x86)\Microsoft Office\Office14\1033\EXPTOOWS.XLA
    Or just do a search of C: for EXPTOOWS.XLA

    You find that this is a hidden file, so you many need to change Windows Explorer to “Show hidden files”
    You may need administrator rights to save the file:
      - Click Start, All Programs, Microsoft Office
      - Hold down the Shift key and right-click Microsoft Excel
      - Click Run as Administrator
      - In Excel, click File, Open and navigate to C:\Program Files\Microsoft Office\Office14\1033
        and open the EXPTOOWS.XLA file.

     
  • Press Alt-F11 to display the Excel macro editor and the find the EXPTOOWS.XLA file
     
  • Find the line containing "lVer = Application.SharePointVersion(URL)" and change it "lVer = 2".
    (That's LVer, not iVer or 1Ver)

    Update: To play it safe, just add the lVer =2 at the end of the Initialize subroutine:
      image
     
  • Save the file. Click “Save changed and discard signature” to overwrite the old file.

More info here: http://msmvps.com/blogs/obts/archive/2006/12/05/384536.aspx

The only problem with this fix is that when you save the change you lose the digital signature from Microsoft on the macro file.

 

.

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.