Copying functional bands with VBA

C

Cadpartner

When I copy/paste a functional band made in a cross-functional flowchart with
the VBA code "Application.ActiveWindow.Page.Paste" the copied band is not
pasted but a new band is drawn instead. How come and what can I do to solve
the problem?
 
J

JuneTheSecond

I have tested as you, and pasted as edited by me.
Please, tell us more, to solve you problem.
 
S

Staffan

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)
 
J

JuneTheSecond

Please, insert sh.Master.Shapes(1).Text = sh.Text
in the range of for and if block.
It seems to me it is a kind of bug in Visio.
 
S

Staffan

Thanks for your quick reply. Yes I thought it was some kind of bug. I will
solve this in another way because I also want the formatting to be copied.

Do you have any idea wy the AlertResponse doesn't seem to work here?

/Staffan
 
M

Mark Nelson [MS]

Cross-functional flowchart is implemented as a Visio add-on. Add-ons are
supposed to respect AlertResponse, but there are still several that have not
been updated to do so.

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top