3

I created 300+ page Visio drawing by importing data to create 300+ "org charts".

I say "org charts' bc they are actually drawings of a Crystal Report as 'CEO' and its datasource tables and fields as "employees".

I now have one huge Visio file with 300+ pages, each page is one report and its datasources. But my goal is to get 300+ separate documents each named appropriately. Using vba i can rename each page as desired or obtain desired name from page.

Ideally i want to have pdf files, not visio files but in pinch would do, and last desirable would be as jpg/gif.

I have tried:

  • exporting/saving each page as jpg/gif/html but get 920 error.. i am totally stumped after exhaustive search on how to modify resolution for each page to avoid 920 error, i mean what is the 'perfect' resolution required? very vague documentation available.

    Sub ExportPagesAsFiles()
    
    Dim PagsObj As Visio.Pages
    Dim PagObj As Visio.Page
    Dim ExportName As String
     Dim ExportPath As String
    
    Set PagsObj = ActiveDocument.Pages
    
    'Open "C:\temp\exportLog.txt" For Output Shared As #1
    
     For Each PagObj In PagsObj
        ExportPath = "c:\Report_Visio\"
         ExportName = ExportPath & PagObj.Name & ".jpg"
        ' ".gif"
        ' ".wmf"
         ' ".html"
        'Print #1, ExportName
        PagObj.Export ExportName
    
    Next PagObj
    
    'Close #1
    
    End Sub
    
  • printing to pdf printer but hit pdf software dialogue (CutePDF). I have no admin rights to modify system registry and I am on Windows 7 machine and sendkeys is outlawed.

  • vba to create new doc, copy/paste page drawing into it, name new doc, save it with name. But some Visio quirk only copy paste page objects but not the captions and data behind them so they are blank shapes. Copying entire page contents is not clear to me after exhaustive search.

  • vba to save copy of 300+ doc with name of first page, then delete rest of pages. Open original 2nd time, save as second page, then delete rest of pages, and repeat 300+ times. I quit this after 10 or so pages and 3 hours.

Seems every possible solution path hits pitfalls, swamps, cliffs ..

As a general note, there is either very spartan, or obtusely technical, Visio information available on internet. With any other Office product, there are loads of info, examples, etc in forums etc. But Visio its crickets.

So wonder if any Visio developers can help me choose and navigate these solution paths!

Thanks.

Edit to add: I am using Visio Standard 2003 version Edit to add Visio export to file code used

curtisp
  • 2,227
  • 3
  • 30
  • 62
  • Can you provide the VBA code that you are using for the PJG/GIF/HTML output? Having that available may help people answer about the 920 error. – saveenr Jan 07 '13 at 19:55
  • Updated to add code .. very basic. Works until hits 920 error which i understand is export file resolution exceeds some Visio notion of exceptional (though page which doesn't export is same as one that does in terms of page size, # shapes/connectors, etc and doesn't have objects in page periphery). – curtisp Jan 07 '13 at 20:48
  • Try PDFCreator. It makes jpg or png per page. You just have to print document to PDFCreator virtual printer. More details in my answer. – Kamil Jan 07 '13 at 21:04
  • Thanks Kamil but I have no admin rights to machine and I cannot install software. – curtisp Jan 07 '13 at 21:23

2 Answers2

2

You can try to use PDFCreator (its open source).

It's a virtual printer, that prints to PDF, JPG, BMP, PNG (very useful for charts) and many other formats.

It has auto save option, configurable filenames and it can save printed document pages as separate files.

Some screenshots from application that configures virtual printer (this is PDFCreator 0.9.6).

Printing each page to separate file

printing each page to separate file

Auto-save options:

enter image description here

Kamil
  • 13,363
  • 24
  • 88
  • 183
1

I've decided to take a different approach.

I used VBA and Access to create each Visio page separately, instead of creating a 300+ page Visio doc. Visio's Org Chart import data wizard is powerful but leaves one stuck for options to get individual pages out, as I outlined above.

So, in Access, I looped through 300+ report records, selecting each report's data, one at a time, creating Visio drawing for that report, naming Visio file as report name and then saving and closing it.

Then I ended up with 300+ Visio files, each one showing a report's datasource tables and fields. Good enough.

Using VBA to create chart from data 'orgwiz' http://office.microsoft.com/en-ca/visio-help/make-visio-organization-charts-from-personnel-files-HA001077464.aspx

The code is

    Set objVisio = CreateObject("Visio.Application")
    Set objAddOn = objVisio.Addons.ItemU("OrgCWiz")

    strCommand = "/DATASOURCE=c:\temp\MyDatabase.mdb, " _
    & " TABLE=MyVisioDataSource, " _
    & " DBQUALIFIER=Microsoft.Jet.OLEDB.4.0 " _
    & " /NAME-FIELD=Data_Object_Name " _
    & " /UNIQUEID-FIELD=Data_Object_ID " _
    & " /MANAGER-FIELD=Data_Object_Parent_ID " _
    & " /DISPLAY-FIELDS=" & strDisplayFields _
    & " /CUSTOM-PROPERTY-FIELDS=" & strPropertyFields _
    & " /SYNC-ACROSS-PAGES " _
    & " /HYPERLINK-ACROSS-PAGES " _
    & " /SHAPE-FIELD=MASTER_SHAPE " _
    & " /PAGES=" & strReportName

    objAddOn.Run ("/S-INIT")

    Dim cmdArray, i
    cmdArray = Split(strCommand, "/")
    For i = LBound(cmdArray) To UBound(cmdArray)
    objAddOn.Run ("/S-ARGSTR /" + cmdArray(i))
    Next

    objAddOn.Run ("/S-RUN ")
curtisp
  • 2,227
  • 3
  • 30
  • 62