Background Sheet swap

 

I've searched the forum and found references to this question, but not an answer. After speaking with GTAC, it appears that it is not possible anyway. We changed our Draft template. I want to copy or import the background sheets of the new template and replace the current background sheets of an open drawing. Since there are no calls for this, I may be reduced to 2 options:

1. Delete all sheets, recreate each background sheet. Open new template, activate proper background sheet, and then copy/paste on newly created sheet.

2. Active proper sheet, delete all objects. Open new  template, activate proper background sheet, and then copy/paste on newly created sheet.

Of course, if there were a Import Background Sheet or something, it would be a simple process. But since there isn't has anybody performed this or a similar function programmatically? Prefereably VB6?

Thanks,

 - Bill

 

Posted by: Bill Ledbetter
Post date: 10/30/2007 3:30:44 AM

1 REPLY

RE: Background Sheet swap

 

Got it. I passed the the document object to this sub-routine and then opened the "Master" template with which to copy from:

Public Sub SetBorders(objdoc As DraftDocument)

 

Dim m As Integer

Dim n As Integer

Dim CurrBack

'Get active Sheet to restore later

CurrBack = objdoc.ActiveSheet.Name

'

'Delete all current backgrounds. Since our active Background sheets begin "Size -", only search for those Backgrounds

'

For m = 1 To objdoc.Sheets.Count

    If Left(objdoc.Sheets.Item(m).Name, 4) = "Size" Then

        objdoc.Sheets.Item(m).Activate

        Set objSelectSet = objdoc.SelectSet

        Call objSelectSet.AddAll

        objSelectSet.Delete

    End If

Next

'

'Now Copy each Sheet from the new Draft file

'

Set Magnatech = objApp.Documents.Open("Master.dft")

For m = 1 To Magnatech.Sheets.Count

    If Left(Magnatech.Sheets.Item(m).Name, 4) = "Size" Then

        Magnatech.Activate

        Magnatech.Sheets.Item(m).Activate

        Set MAGSelectSet = Magnatech.SelectSet

        Call MAGSelectSet.AddAll

        MAGSelectSet.Copy

    objdoc.Activate

'

'Compare against name of Current Draft and replace if they match

'

    For n = 1 To objdoc.Sheets.Count

        If objdoc.Sheets.Item(n).Name = Magnatech.Sheets.Item(m).Name Then

            objdoc.Sheets(n).Activate

            Call objApp.ActiveDocument.Windows(1).Paste

        End If

    Next

    End If

Next

'

'Close Magnatech.dft template

'

Magnatech.Close savechanges = no

'

'Reset to proper background

    objdoc.Activate

    objdoc.Sheets.Item(CurrBack).Activate

End Sub

 

 

Posted by: Bill Ledbetter
Post date: 10/30/2007 9:56:57 AM