Reputation: 2325
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
Upvotes: 3
Views: 4922
Reputation: 2325
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 ")
Upvotes: 1
Reputation: 13941
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
Auto-save options:
Upvotes: 2