Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Word Automation : could not open macro storage

My application (vb.net windows application deployed via ClickOnce) uses Word to open and fill .dot templates to create new Word documents. I reference Microsoft Word 14 Object Library and uses this code :

Dim oWord As Word.Application = Nothing
Dim oDoc As Word.Document = Nothing
Try
    oWord = New Word.Application
    Dim strFileName As String = ""
    Select Case strType
        Case "LettreReception"
            strFileName = Path.Combine(GetParam(1), "Template_LettreReception.dot")
            If File.Exists(strFileName) Then
                oDoc = oWord.Documents.Add(strFileName)

On the last line I receive "could not open macro storage" error on deployed machines (not on my development machine).

I develop with Windows 7 - Office 2010 - VS 2010 (.Net 3.5). My deployment machine is also a Windows 7 with Office 2010 installed.

I tried to remove normal.dotm (I found some links advicing it) without success. The .dot template used contains no macro.

like image 649
Joss57 Avatar asked Dec 28 '22 04:12

Joss57


1 Answers

Check the properties of the word document and make sure the files are unblocked. Sometimes when you get the documents from a different computer or download them from the internet they will be blocked which will cause the the throwing of this exception "could not open macro storage"

like image 181
Oday Hazeem Avatar answered Jan 06 '23 16:01

Oday Hazeem