Author Topic: dupilcating pages and naming it from excel  (Read 948 times)

0 Members and 1 Guest are viewing this topic.

chathavardhan

  • Jr. Member
  • **
  • Posts: 41
dupilcating pages and naming it from excel
« on: August 31, 2012, 04:52:38 AM »
Hello all,

I am duplicating visio pages using vba, now I am trying to create number of pages mentioned in excel "A" column and name the pages accourding to the text in that column.


I can create 10 pages with this condition "for i = 1 to 10" using this condition but now i want to create number of pages as mentioned in excel can any one please help.

If my question is not clear plz reply back so that i can explin in better way.

Thank you.

Get Visio Guy's new book!


chathavardhan

  • Jr. Member
  • **
  • Posts: 41
Re: dupilcating pages and naming it from excel
« Reply #1 on: August 31, 2012, 06:20:05 AM »
Can any plz reply for this question ita really important for me

Visit the Visio Guy web site at www.visguy.com for hundreds more articles on Visio!


Paul Herber

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1639
    • Sandrila Ltd
Re: dupilcating pages and naming it from excel
« Reply #2 on: August 31, 2012, 06:48:34 AM »
Here is another very recent topic about how to read data from an Excel spreadsheet:

http://visguy.com/vgforum/index.php?topic=4199.msg16394#msg16394

I just did a search for 'Excel code' in this forum
Engineering and software stencils and applications for Visio - http://www.sandrila.co.uk/
Twitter: http://twitter.com/sandrilaLtd

chathavardhan

  • Jr. Member
  • **
  • Posts: 41
Re: dupilcating pages and naming it from excel
« Reply #3 on: August 31, 2012, 06:57:18 AM »
Thank you Paul,

But i am trying to create visio pages by using the range of  cell "A" in excel for example in excel A column has 10 numbers then visio has to create 10 pages something like that. Hope you understand what I am trying to do. If you have any questiond feel free to get back to me.


Paul Herber

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1639
    • Sandrila Ltd
Re: dupilcating pages and naming it from excel
« Reply #4 on: August 31, 2012, 07:00:47 AM »
Yes, I fully uinderstand, modify that example code to read your spreadsheet cells.
Engineering and software stencils and applications for Visio - http://www.sandrila.co.uk/
Twitter: http://twitter.com/sandrilaLtd

Jumpy

  • Hero Member
  • *****
  • Posts: 817
Re: dupilcating pages and naming it from excel
« Reply #5 on: August 31, 2012, 07:21:13 AM »
Code: [Select]
Dim i as integer
Dim w as Worksheet
Dim c as Collection
Set c = New Collection
Set = ActiveWorkbook.Worksheets(1)

'1. Get Names From Excel and store in a collection
For i=1 To w.usedRange.Rows.Count
  If w.cells(i,1).value<>"" then
    c.Add w.cells(i,1).value
  End If
Next i

'2. Create Pages
Dim s as Variant
For Each s in c
  'Create a page with name s
Next s


aledlund

  • Hero Member
  • *****
  • Posts: 1172
Re: dupilcating pages and naming it from excel
« Reply #6 on: August 31, 2012, 07:29:55 AM »
There's actually two processes that have to be developed in two different models, the first model being excel and the second being visio. The first piece of vba code is the excel functionality to be able to read a workbook/worksheets. The second is a trivial piece of code to add the page to the drawing.

This article has vba code that demonstrates opening and reading an excel document
http://visguy.com/vgforum/index.php?topic=2474.msg10853#msg10853
The modExcel module has some example code.

There's also examples of roundtripping data to Excel in this example code
http://www.visguy.com/2009/04/08/path-analysis-in-visio/

As far as adding a page to document, that code is in the Visio SDK.
AL