Hi Ed,
I'm well on the way with this.
I'm using Sendkeys to move the documents to the correct page number (this
wasn't simple, either - I eventually found somewhere - I think it was in MS
Access documentation online - that the 2nd parameter only pauses execution
which the keystrokes are executed, not the result of the keystrokes. A delay
must be introduced after Sendkeys to allow the result of the keystrokes to
execute.)
I have programatically positioned the main document to the empty page that I
want to copy to, opened and copied the first page of the 2nd document, and
pasted it shape by shape into the main document. So far, so good.
My problem now is that while I can move to the next empty page in the main
document, I cannot make the 2nd document the active document, so that the
Sendkeys code will execute on it.
my code:
'oDoc is the 1st or main document, 'Report.pub'
'StateDoc is the 2nd document, 'State.pub'
'Ive tried putting in the following delay loop to check
'if/when the 2nd document becomes the active document,
'but it never does.
' Do
' If oApp.ActiveDocument.Name = "State.pub" Then Exit Do
' Call DelayProgram(0.01)
' Loop
i = 0
For Each oStatePage In oStateDoc.Pages
i = i + 1
oStateDoc.ActiveWindow.Activate
Call DelayProgram(SendkeysDelay)
'goto page
SendKeys "{F5}", True 'displays the go to page box
Call DelayProgram(SendkeysDelay) 'SendkeysDelay is delay in seconds
'DelayProgram contains a do..loop which exits after the delay
elapses
'current delay is 0.5 secs, probably far too long
SendKeys CStr(i), True 'enteres the page number
Call DelayProgram(SendkeysDelay)
SendKeys "{ENTER}", True 'hits the [OK] button
Call DelayProgram(SendkeysDelay)
'temp = oStatePage.PageNumber
oStateDoc.ActiveWindow.Activate
Call DelayProgram(SendkeysDelay)
oStatePage.Shapes.SelectAll
Call DelayProgram(SendkeysDelay)
oDoc.ActiveWindow.Activate
Call DelayProgram(SendkeysDelay)
SendKeys "{F5}", True
Call DelayProgram(SendkeysDelay)
SendKeys CStr(Pagenum + i), True
Call DelayProgram(SendkeysDelay)
SendKeys "{ENTER}", True
Call DelayProgram(SendkeysDelay)
j = 1
oStateDoc.ActiveWindow.Activate
Call DelayProgram(SendkeysDelay)
For Each pubShape In oStatePage.Shapes
oStateDoc.ActiveWindow.Activate
Call DelayProgram(SendkeysDelay)
oStatePage.Shapes.Item(j).Copy
Call DelayProgram(SendkeysDelay)
oDoc.ActiveWindow.Activate
Call DelayProgram(SendkeysDelay)
oDoc.Pages(Pagenum + i).Shapes.Paste
Call DelayProgram(SendkeysDelay)
j = j + 1
Next
Next
end code:
Any thoughts on this?
regards,
Phil.