Click here to Skip to main content
Sign Up to vote bad
good
See more: COMWordVC
I want to open a doc file by the way as follows;
_Application wApp;
wApp.CreateDispatch(L"Word.Application");
Documents wDocs = wApp.GetDocuments();
COleVariant vNotFind(DISP_E_PARAMNOTFOUND, VT_ERROR);
_Document wDoc = wDocs.Open(COleVariant("...doc"), vNotFind,vNotFind,vNotFind,vNotFind,vNotFind,vNotFind,vNotFind,vNotFind,vNotFind,vNotFind,vNotFind,vNotFind,vNotFind,vNotFind,vNotFind);
 
But when it goes to "wDocs.Open(", the macro as follows in doc file will run.
 
Sub autoopen()
MsgBox "hello"
End Sub

 
how to stop it?
My english is just-so-so, so forgive me.
Posted 8 Feb '12 - 0:23

Comments
SAKryukov - 8 Feb '12 - 11:00
Good question, because this is important thing, my 5. --SA

1 solution

Your English did not betray you; I wish other inquirers could write so correctly and clearly.
 
It is very important to switch off macro processing, because macro is dangerous feature. I checked my Word installation; it is using by default the option like "disable macros except trusted locations", and the trusted locations are only those created by the Word installation, not where I can normally copy the document.
 
So, that said, you should take care about it in the Word settings. The procedure depends on your Word version. Check or search for "disable macros" in your help. In newer versions it's done via "Word Settings" -> "Trust Center".
 
For example:
http://office.microsoft.com/en-us/word-help/enable-or-disable-macros-in-office-documents-HA010031071.aspx[^],
http://office.microsoft.com/en-us/word-help/enable-or-disable-macros-in-office-files-HA010354316.aspx[^].
 
See also (for older versions): "How to switch off bad features of MS Word
and other Windows problems", http://www.thuto.org/ubh/ub/compu/hcsmsw1.htm[^].
 
Keep it safe,
—SA
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 330
1 OriginalGriff 315
2 Slacker007 240
3 Aarti Meswania 210
4 Dave Kreskowiak 202
0 Sergey Alexandrovich Kryukov 8,743
1 OriginalGriff 7,124
2 CPallini 3,678
3 Rohan Leuva 3,011
4 Maciej Los 2,403


Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 8 Feb 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid