OK this is the VBA-code that I use to search for a functional band and then
copy it to a new page. If I do it manually it works fine, even if I stop the
code before the Paste-code and paste it manually theres is no problem.
I also have another problem with the code, the AlertResponse doesn't seem to
work for the question about copying bands that is shown when a new page is
added. Therfore I need to click Cancel when using the macro.
I justed found something interesting. If there is already functional bands
on the new page (if I click OK instead of Cancel) the macro works but if the
page is empty it doesn't.
Sub Cross_Functional()
Dim page1 As Long
Dim page2 As Long
Dim sh As Shape
Dim vsoPage1 As Visio.Page
page1 = Application.ActivePage.ID
Application.AlertResponse = 2
Set vsoPage1 = ActiveDocument.Pages.Add
page2 = Application.ActivePage.ID
Application.ActiveWindow.Page =
Application.ActiveDocument.Pages.ItemFromID(page1)
For Each sh In ActivePage.Shapes
If InStr(1, sh.NameU, "Functional band", vbTextCompare) = 1 Then
Application.ActiveWindow.DeselectAll
ActiveWindow.Select sh, visSelect
Application.ActiveWindow.Selection.Copy
End If
Next
Application.ActiveWindow.Page =
Application.ActiveDocument.Pages.ItemFromID(page2)
Application.ActiveWindow.Page.Paste
Application.AlertResponse = 0
End Sub
/Staffan (I have changed my display name)