J
Jesper
Hi
I have written the following test program, to test an issue I have with
word. When the programs run, it open a new document based on a given
template file. Then It should add some custom variable to the newly created
document.
The problem is, when program just run, and I close word after edited the
doc, then word ask it I will save changes to the template file also, like the
custemvariables is put into the template instead of the ducument. When I
single step debug the program, then the behavior is as expected. Can I
somehow test, when word is ready and has fully instantiated the newly created
document??
Pls help with a solution.
This worked as (I) expected in version 2003.
Same with outlook. Some automation error occours if outlook is not allready
running, and I ask outlook for username just after created (started) it by
automation. Same, if debugging give outlook time to startup while debug, no
error occours.
----------------------------
Sub test()
Set Newdoc =
Application.Documents.Add("\\grpsrv2\cmsdata$\produktion\skabeloner\public.dot", , , True)
PropFound = False
Application.Activate
For Count = 1 To Newdoc.CustomDocumentProperties.Count
If Newdoc.CustomDocumentProperties.Item(Count).Name = "ProductId" Then
PropFound = True
Newdoc.CustomDocumentProperties.Item(Count).Value = CurrentProductId
Exit For
End If
Next
If Not PropFound Then
Newdoc.CustomDocumentProperties.Add "ProductId", False, 4,
CurrentProductId
End If
End Sub
I have written the following test program, to test an issue I have with
word. When the programs run, it open a new document based on a given
template file. Then It should add some custom variable to the newly created
document.
The problem is, when program just run, and I close word after edited the
doc, then word ask it I will save changes to the template file also, like the
custemvariables is put into the template instead of the ducument. When I
single step debug the program, then the behavior is as expected. Can I
somehow test, when word is ready and has fully instantiated the newly created
document??
Pls help with a solution.
This worked as (I) expected in version 2003.
Same with outlook. Some automation error occours if outlook is not allready
running, and I ask outlook for username just after created (started) it by
automation. Same, if debugging give outlook time to startup while debug, no
error occours.
----------------------------
Sub test()
Set Newdoc =
Application.Documents.Add("\\grpsrv2\cmsdata$\produktion\skabeloner\public.dot", , , True)
PropFound = False
Application.Activate
For Count = 1 To Newdoc.CustomDocumentProperties.Count
If Newdoc.CustomDocumentProperties.Item(Count).Name = "ProductId" Then
PropFound = True
Newdoc.CustomDocumentProperties.Item(Count).Value = CurrentProductId
Exit For
End If
Next
If Not PropFound Then
Newdoc.CustomDocumentProperties.Add "ProductId", False, 4,
CurrentProductId
End If
End Sub