Thanks so much for this firsttube. It has helped immensely. I've changed it to loop through the drawings and relink them to the defined new data connection. I have several projects with dozens of drawings linked to different databases. All of these databases are in the same instance but are being upgraded and moved to a new instance of SQL Server. What I would like to do is to either: 1. Best Case - Loop through all of the drawings, set the data connection by splitting (or trimming) the drawing.linkSource and extracting the database name then append a "02" to it (each datasource for the new databases will be the database name with 02 on the end). I'm not sure if this is doable. 2. Worst Case (but not a huge deal if I have to go this route as I there are only about 15 databases) - Run the script for each databases data source defined manually. To do this, however, I need to add a statement whereby if the drawing.linkRowset.geometry is not listed in the in the tables for that data source then it skips it (or uses ButtonCancel to cancel out of the dialog) and moves to the next. Currently, if it comes to a drawing that is not listed in the tables for the defined data sources then it relinks it to the first one in the list! So this is what I was attempting but it's it doesn't work. Any insight, thoughts appreciated. sub main 'vbscript geomName = "Geometry" set compset = document.componentset set ui = Application.UserInterface set proj = ui.Panes("Project") 'loops through drawings for each cmp in compset if cmp.type=ComponentDrawing then set tree = proj.ControlSet("TreeViewComponents") tree.Text = cmp.Name 'set dataconnection equal to database name + 02 by splitting Link Source string set mySource = cmp.linkSource set myArray = Split(mySource, "Database=") set newDataConName = TRIM(myArray(1)) & "02" ui.InvokeCommand "ViewProjectReLink", "pane: Project" Do' Nothing Loop Until UI.ModalDialog.Caption = "Data Source" set dlg = ui.modaldialog set ctrlset = dlg.ControlSet 'select new datasource ctrlset("ListViewDataSources").Text = newDataConName ctrlset("ButtonOK").Push() 'wait Do:x=x+1: Application.History.Log x & vbnewline Loop Until UI.ModalDialog.Caption = "Link Drawing" set dlg = ui.modaldialog set ctrlset = dlg.ControlSet 'set all the link options ctrlset("ComboBoxType").Text = "Drawing" ctrlset("ComboBoxSource").Text = cmp.LinkRowSet & "." & geomName ctrlset("ComboBoxVersion").Text = "[None]" ctrlset("ButtonOK").Push() end if next end sub *edit - I do realize I have a trailing ; after the database name which i can put in my new datasource name or trim to remove
Gloria Dangerfield, GIS/Database Coordinator Grey Sauble Conservation, ON Canada g.dangerfield@greysauble.on.ca GIS Applications Specialist, Partner, Grey Bruce GeoSpatial |