How to manually fix content error in Microsoft Word


Word2013_error1

Today while I was editing a document suddenly Word crashed and the document became unable to be opened. Every time I wanted to open it the same error was:

We’re sorry. We can’t open DocumentName.docx because we found a problem with its contents.
When I want to see Details the following message shows:
Unspecified error
Location: Part: /word/document.xml, Line 2, Column: 0.

Then I wanted to open auto-saved version of the document, the same error appeared. So I changed the DocumentName.docx  file in to DocumentName.zip, and extract the content, found document.xml file and opened it in Notepad++.

The picture below shows the content of the DocumentName.docx file, renamed in to zip and extracted:

Word2013_error2

If you didn’t know the word document with doc or docx extension is actually zip file, which you can extract.

I have opened the docuemnt.xml and try to find error in second line. This was mission impossible because all xml content is placed in this line. As you can see on the picture below:

Word2013_error3

To find which element cause the content problem we have to format XML content. I prefer using Notepad++ and XML Tool PlugIn. It can be installed through Plungins menu of Notepad++.

Word2013_error4

To format xml content choose option Pretty print (XML only – with line breaks) . After the content is formatted, back the Document.xml to zip, change the extension from zip to docx, and open the word document.

The same error appear, but when you choose for details you can read in which line is the error. Find the line in Notepad++ and delete whole tag element:

Word2013_error7

Copy document.xml back in to zip file, rename the extension and try to open. If you have another error, repeat the process again, otherwise your document is opened.

Word2013_error8

Advertisement

WinDays13 – kratki utisci, pptx datoteka i demo primjeri


Još uvijek traje jedna od najvecih Microsoft konferencija u regionu, i nakon dva dana konferencije mogu reći da su ovi WinDaysi do sada najbolje organizirana konferencija. Preko 1000 registrovanih polaznika i stotinjak predavača samo su neke od statističkih brojki ove konferencije.

Da je ovo prava developerska konferencija između ostalog možemo se uvjeriti na dobroj posjećenosti dev predavanja. Prvog dana konferencije najzanimljiviji dijelovi možemo kazati da su bili ITPro i Dev keynote , a posebno je interesantnan bio keynote od Damir Dobrića koji je zbog štrajka radnika avio-kompanije, javljanje održao preko Skypea sa ljubljnskog aerodroma. Drugog dana nastavilo se u dobrom raspoloženju, a sada već tradicionalna večera predavača desila se u restoranu nedalok od konferencije u pravom istarskom stilu.

Drugog dana konferencije održao sam predavanje na temu MVVM u razvoju WP8 i Windos store aplikacija, i sa zadovoljstvo mogu reći da je proteklo u dobroj atmosferi sa prepunom salom. Kao što sam najavio prethodno moje predavanje oko MVVM tehnike na WP8 i WinRT bilo je drugog dana konferencije. Ovim pute se zahvaljujem svim posjetiocima predavanja i kao što sa obećao demo primjere i prezentacijku datoteku objavljujem na kraju posta.

20130424_095628

20130424_100501

20130424_094223

20130423_192036

20130422_214523

20130422_191850

20130422_191736

20130422_165302

Oktobarski sastanak Bihac .NET UG


Termin sastanka: 31. 10. 2012. 17:00, Tehnički fakultet Bihać

Nakon ljetnje pauze i septembaskih obaveza zakazujemo naredni sastanak Bihac .NET UG. Naime, u srijedu 31. oktobra sastaćemo se na starom mjestu, na Tehničkom fakultetu u Bihaću i održati sastanak na temu razvoja Windows 8 aplikacija. Ovog puta moja malenkost će održati predavanje pod nazivom “Consuming data in Windows 8 Store apps” u narednom tekstu date su detaljne informacije o predavanju.

Tema: Consuming data in Windows 8 Store app / Konzumacija podataka u Windows 8 Store aplikacijama

Level: 300

Predavač: Bahrudin Hrnjica, Microsoft MVP

Opis: Windows 8 Store aplikacije izvršavaju se u izoliranom okruženju kojim upravlja Windows Run-Time. Ova okolina pruža mogućnosti razvoja aplikacija pod nazivom Windows Store app, odnosno novi tip aplikacija koje se vrte na Windows 8 OS. Jedna od karakteristika ovih aplikacija je što su prilagođene za pokretanje na raznim uređajima od notebooka, tableta do PCa, i što mogu da se distribuiraju na Windows Store globalnu prodavnicu Windows 8 aplikacija. Jednistvenost platforme daje i određena ograničenja, a u ovom predavanju ćemo vidjeti na koji način Windows Store aplikacijama obezbijediti podatke iz različitih izvora podataka, a posebno sa SQL Servera. Widnows Store aplikacija nisu u mogućnosti da direktno pristupe Entity Framework ORM maperima, pa smo prisiljeni da koristimo ili ASP.NET Web API ili WCF. Demo primjeri će pokazati kako koristiti HTTPClient klasu za pristup podacima preko pomenutih serverskih tehnolgija. S druge strane na predavanju će biti pokazano kako koristiti SQLite C++-cross-platform biblioteku u Windows Store applikacijama direktno bez korištenja pomenutih Rest i WCF tehnologije. Kroz demo primjere predavanje će dati kompletnu sliku kako Windows Store aplikacija mogu koristiti podatke iz vanjskih izvora bez kojih je teško zamisliti današnju modernu Windows 8 Store aplikaciju.

Na sastanku će biti i nekoliko nagrada na najsretnije i najaktivnije članove. Nagrade su: majica, usb stik, …..

Developing Windows Store App Part 1: Database Model


This is the first of several blog posts about developing Windows 8 Store app. The first blog post will show how to implement database model which will be used in our application. If you want to get more information about the application we are developing please see the previous announcment post. Before we start with the tutorial, several requirements must be satisfied:

1. You need to have installed at least Visual Studio 2012 Express

2. You need to have at least SQL Server 2008 or 2012 Express.

Our database model is very simple. We have three tables: Places, Dishes and Towns. Relation of those tables shows the picture below.

SQL database will also be provided by the end of the blog post. Now that we have database model on the paper, we can start with implementation. We will use Entity Framework 5, and Code First technology in order to implement db model.
Start Visual Studio 2012, choose File->New->Project. Choose ClassLibrary similar as picture below.

After we created the empty Class Library project, we can start with implementation of the entities. According to db model shoed earlier, we are going to create three .NET classes: Dish, Town, Place. In order to do that:

  • Right Click at the Project
  • Add New Class
  • Give name: Dish

Repeat the process for Town and Place. Text below shows the implementation of classes.
Town class:

public partial class Town
{
public int? TownID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Image { get; set; }
//relation 0-oo
//many places can be in one Town
public ICollection Places { get; set; }
}

Dish class:

public partial class Dish
{
    public int? DishID { get; set; }
    public string Name { get; set; }
    public string Slogan { get; set; }
    public string Description { get; set; }
    public string Image { get; set; }
    //relation 0-oo
    //many places can have one dish
    public ICollection<Place> Places { get; set; }
}

Place class:

public partial class Place
{
    public int? PlaceID { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public int? DishID { get; set; }
    public string Slogan { get; set; }
    public string Type { get; set; }
    public int? TownID { get; set; }
    public string Image { get; set; }
    //one relation to Dish
    public Dish PlaceDish { get; set; }
    //one relation to Dish
    public Town PlaceTown { get; set; }
}

Since we are using Code First, we need to specify the relation between entities too. That’s why we have put the last two properties in Place class, and also IColletion property of the previos classes. This is enough information that Code First make relation between tables on SQL Server.  By default PlaceID is primary key for Place table, as well as DishId and TownID for corresponded tables.
Now that we have entities, we need to implement DBContex, central class for handling all operation and transaction against database. Before we implement DBContext we need to add Entity Framework reference. Since EF is separated from the .NET we can use NuGet to accomplish this.
1. Right click on Reference, choose Manage NuGet package

In Search box type: Entity Framework and hit enter. Package will appear in the list. Click Install button. Picture below shows Manage NuGet Package dialog. Accept license agreement, and close the dialog.

CExplorer DataContext class:

public class CExplorerContext: DbContext
{
    public CExplorerContext() : base("cexplorer_db")
    {
        Configuration.LazyLoadingEnabled = false;
    }

    //entity sets
    public DbSet<Place> Places { get; set; }
    public DbSet<Dish>  Dishes  { get; set; }
    public DbSet<Town>  Towns  { get; set; }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        //crating one to many relation between Town and Place
        modelBuilder.Entity<Place>()
            .HasRequired(x => x.PlaceTown)
            .WithMany(d => d.Places)
            .WillCascadeOnDelete(true);

        ////crating one to many relation between Dish and Place
        modelBuilder.Entity<Place>()
            .HasRequired(x => x.PlaceDish)
            .WithMany(d=>d.Places)
            .WillCascadeOnDelete(true);

        base.OnModelCreating(modelBuilder);
    }
}

As you can see, we have overridden ModelCreation virtual method and implement relation between entities. This is classic one to many relation.

At the end of the implementation, we need to provide connection string to SQL Server, it must be with the same name as we specified in the implementation od the DBContext.

1. Add New Item: App.config file and put the following configuration.

Based on SQL instance name, change the connection string. Database could not exist on the SQL server. If there is a database on the SQL with the same name, EF will add table in to existing database.

Before we end the today’s post, lets quickly create Console Test application to make sure we implemented correct model.

1. File->New->Add New Project
2. Console Application

Like previous add Entity Framework by NuGet.
Add reference of EFModel.
Open Program.cs and put the following implementation:

class Program
{
    static void Main(string[] args)
    {

        CExplorerContext ctx = new CExplorerContext();

        var dish = new Dish() { DishID = 1, Description = "Description", Name = "DishName", Slogan = "Slogan", Image = "Default.jpg" };
        var town= new Town(){TownID=1, Name= "TownName", Description="Description", Image=""};
        ctx.Dishes.Add(dish);
        ctx.Towns.Add(town);
        ctx.SaveChanges();
        var place = new Place() { PlaceID = 1, Name = "Place Name", Description = "DEscription", Image = "default.jpg", Slogan = "Slogan title", DishID = 1, TownID = 1 };
        ctx.Places.Add(place);
        ctx.SaveChanges();

        var plc = ctx.Places.FirstOrDefault();
        Console.WriteLine("Place from Database");
        Console.WriteLine("Place from database Name:{0}", plc.Name);
        Console.Read();

    }
}

After we run, output console shows that the entities are inserted successively on database.

In other words Cexplorer_DB database is created on the SQL server, and entities are inserted from the test.

Code First approach is very powerful, we only need to specified connection string, and everything is created just like we do, in Model First approach.  Complete source code for this Demo can be found here.