Application loses its control when opening MS Word by msword8

Hello experts,

My application is using the msword8 to open a Word document.

If the Word document doesn't containt any Macro then there is no problem.

However if the Word document contains any Macro then my appliaction loses its contol to the opening Word document and I can not come back to my application.

Could you please give me some hints solve this problem?

Thanks in advance!
Well try posting some code so i can see what actually is going on :)
Ah yes, sorry

COleVariant m_True((short)TRUE),m_False((short)FALSE), m_Long((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
int result, pos;
CString *temp, val;
_Application app;
Variable oVar;
Documents oDocs;
_Document oDoc;
Variables oVars;
if(!app.CreateDispatch(_T("Word.Application"))){
AfxMessageBox(_T("Can't not start word application!"));
result = -1;
}
else {
result = 1;
app.SetVisible(TRUE);
oDocs = app.GetDocuments();
oDoc = oDocs.Add( COleVariant(pathToFile, VT_BSTR), m_Long);

oVars = oDoc.GetVariables();
int numofVar = oVars.GetCount();
temp = new CString[numofVar];
for(int i=1; i<=numofVar; i++) {
oVar = oVars.Item(COleVariant((long)i));
val = oVar.GetName();
pos = isExist(val, docVariable, varNum);
if(pos!= -1)
oVar.SetValue(textValue[pos]);
}
for(int i=1; i<=numofVar; i++) {
oVar = oVars.Item(COleVariant((long)i));
temp[i-1] = oVar.GetName();
}

for(int i=0; i<varNum; i++) {
if(isExist(docVariable[i],temp, numofVar) == -1)
oVars.Add(docVariable[i], COleVariant(textValue[i]));
}

app.Run(_T("VariablenNeuAnpassen"));

/*oDoc.ReleaseDispatch();
oDocs.ReleaseDispatch();
app.ReleaseDispatch();*/
}
Topic archived. No new replies allowed.