have some VBA code that does the following:
However, when I am doing
, (0 means Do not save changes) I get the following fatal microsoft word error:
The instruction at "0x77ab11e8" referenced memory at "0x001cf9a0". The memory could not be "read"
click OK to terminate the program
Click CANCEL to debug the program
The stack trace if interested are:
Anyone know what is going on and how could I prevent word from crashing?
Code:
Dim objWordApp As new Word.Application
objWordApp.displayAlerts = 0
'template.dot has an ActiveX Control in it.
var objWordDoc = objWordApp.Documents.Add("c:\\dev\\template.dot")
objWordDoc.Windows(1).Selection.TypeText("type something")
objWordDoc.saveAs("c:\\dev\\test.doc")
'The ActiveXControl in the template for some reasons appear to be modifying the template, but I set the template read-only anyway to prevent users from modifying it.
objWordDoc.AttachedTemplate.saved = True
objWordApp.Quit(0)
However, when I am doing
Code:
objWordApp.Quit(0)
The instruction at "0x77ab11e8" referenced memory at "0x001cf9a0". The memory could not be "read"
click OK to terminate the program
Click CANCEL to debug the program
The stack trace if interested are:
Code:
77AB115F call 77B0681C
77AB1164 and dword ptr [ebp-4],0
77AB1168 mov eax,esp
77AB116A mov dword ptr [ebp-10h],eax
77AB116D mov dword ptr [ebp-8],eax
77AB1170 test ebx,ebx
77AB1172 je 77AB11A4
77AB1174 test byte ptr [ebx+4],2
77AB1178 lea edx,[ebx+4]
77AB117B jne 77AB11A0
77AB117D mov edi,dword ptr [ebp-8]
77AB1180 push 7
77AB1182 add dword ptr [ebp-8],1Ch
77AB1186 pop ecx
77AB1187 mov esi,edx
77AB1189 push 7
77AB118B rep movs dword ptr [edi],dword ptr [esi]
77AB118D pop ecx
77AB118E xor eax,eax
77AB1190 mov edi,edx
77AB1192 rep stos dword ptr [edi]
77AB1194 or dword ptr [edx],6
77AB1197 and dword ptr [ebx+40h],eax
77AB119A inc dword ptr [ebp-4]
77AB119D mov edi,dword ptr [ebp-0Ch]
77AB11A0 mov ebx,dword ptr [ebx]
77AB11A2 jmp 77AB1170
77AB11A4 push 77B2AC40h
77AB11A9 call dword ptr ds:[77A51268h]
77AB11AF cmp dword ptr [ebp-4],0
77AB11B3 jbe 77AB1250
77AB11B9 mov eax,dword ptr [ebp-10h]
77AB11BC lea esi,[eax+14h]
77AB11BF mov eax,dword ptr [ebp-4]
77AB11C2 mov dword ptr [ebp-8],eax
77AB11C5 test byte ptr [esi-13h],4
77AB11C9 je 77AB11D8
77AB11CB push dword ptr [esi-4]
77AB11CE xor ebx,ebx
77AB11D0 push ebx
77AB11D1 call 77AB9B7C
77AB11D6 jmp 77AB11DA
77AB11D8 xor ebx,ebx
77AB11DA cmp dword ptr [esi],ebx
77AB11DC je 77AB11FB
77AB11DE mov eax,dword ptr [esi-4]
77AB11E1 cmp eax,ebx
77AB11E3 je 77AB11F3
77AB11E5 mov ecx,dword ptr [eax]
77AB11E7 push eax
77AB11E8 call dword ptr [ecx+8] [-------------- This is the error, I think
77AB11EB mov eax,dword ptr [esi]
77AB11ED push eax
77AB11EE mov ecx,dword ptr [eax]
77AB11F0 call dword ptr [ecx+10h]
77AB11F3 mov eax,dword ptr [esi]
77AB11F5 push eax
77AB11F6 mov ecx,dword ptr [eax]
77AB11F8 call dword ptr [ecx+8]
77AB11FB cmp dword ptr [esi-0Ch],ebx
77AB11FE jbe 77AB120A
77AB1200 mov ecx,dword ptr [edi+10h]
77AB1203 push 1
77AB1205 call 77AAF6CC
77AB120A cmp dword ptr [esi-10h],ebx
77AB120D jbe 77AB1221
77AB120F mov ecx,dword ptr [edi+10h]
77AB1212 xor eax,eax
77AB1214 cmp dword ptr [ebp+8],10h
77AB1218 setne al
77AB121B push eax
77AB121C call 77A678AC
77AB1221 cmp dword ptr [esi-8],ebx
77AB1224 jbe 77AB1238
77AB1226 mov ecx,dword ptr [edi+10h]
77AB1229 xor eax,eax
77AB122B cmp dword ptr [ebp+8],10h
77AB122F setne al
77AB1232 push eax
77AB1233 call 77A678AC
77AB1238 mov ecx,dword ptr [esi+4]
77AB123B cmp ecx,ebx
77AB123D je 77AB1244
77AB123F call 77AB30D1
77AB1244 add esi,1Ch
77AB1247 dec dword ptr [ebp-8]
77AB124A jne 77AB11C5
77AB1250 mov ecx,77B2AC38h
77AB1255 call 77A65183
77AB125A lea esp,[ebp-1Ch]
77AB125D pop edi
77AB125E pop esi
77AB125F pop ebx
77AB1260 leave
77AB1261 ret 4
77AB1264 mov dx,word ptr [esp+4]
77AB1269 xor eax,eax
77AB126B mov word ptr [ecx+8],dx
77AB126F mov dword ptr [ecx],eax
77AB1271 movzx edx,dx
77AB1274 mov dword ptr [ecx+4],eax
77AB1277 mov dword ptr [ecx+1Ch],eax
77AB127A mov dword ptr [ecx+14h],eax
77AB127D mov dword ptr [ecx+10h],eax
77AB1280 lea eax,[ecx+28h]
77AB1283 mov dword ptr [ecx+20h],eax
77AB1286 lea eax,[eax+edx*4]
77AB1289 mov dword ptr [ecx+24h],eax
77AB128C ret 4
77AB128F push esi
77AB1290 push edi
77AB1291 mov edi,ecx
77AB1293 mov ecx,77B2AC38h
77AB1298 call 77A65183
Anyone know what is going on and how could I prevent word from crashing?