开发者

Word 2003 template with VBA macros that does not run properly in Word 2011 for MAC

As the title says, I've got a word template with macros that does not run properly in the new Word version from Office 2011 for MAC.

The thing which seems to not work properly is the following code:

Sub Document_New()
    myForm.Show
End Sub

The same is with Document_Open()

It doesn't seem to run this code on the Mac version.

Does anyone know why this won't work on the Mac, or if there's another way around to emulate the document_open/document_new function?

EDIT: The document is in the .dot format. And I tried to s开发者_开发问答ave it to .doc, then the Document_open() worked just fine, so it seems to not be working in the .dot format.. And Document_New() is not running in .doc since its not a new templatefile based on a document..

EDIT 2: Seems like it was a once only with the Document_open on .doc files. I cant make it work again. So weird! The only event I get working, and this is only when using the .doc file format, is Document_Close() - this works everytime...

EDIT 3: This is just getting weirder. I made a new .doc document with the following code:

Private Sub Document_Open()
    MsgBox ("BlaBlaBla")
End Sub

The code only runs if the Visual Basic Editor is open BEFORE I close the word file and try to open it again. If I close the Visual Basic Editor and then the word file, and then open the word file; The code is not run.

??


All VB application events are suppressed if you have the VB-editor active, and the current project is not running. It is an intentional behavior, to prevent unwanted code execution, hence not debuggable.

I have used Workbook_Open() (in Excel), and I can only see it working on newly open Excel Xls (xlsm on 2010), from a non-open VB-editor Excel application. It will work if you have other doc/xls already open, but not if vb-editor is up.

Have you checked whether Macros are allowed? Do you have generated a certificate and setup your application as a trusted source?


I'm having similar issues. It seems that MS removed support for the Document_New and Document_Open functions in the Word object model for Word 2011. See http://mac2.microsoft.com/vb/1033/Word/html/womscChangesBetweenWord2010and2011.htm

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜