PDA

View Full Version : Page Setup Override in Sheet Set



mcoffman
2008-05-07, 10:26 PM
Does anyone know how to set the page setup override template in a sheetset via vba?

Thanks!
MC

RobertB
2008-05-19, 04:17 PM
Use the SetAltPageSetups method.

mcoffman
2008-05-23, 03:49 PM
Thanks Robert!

I tried this bit of code after your advice and I keep getting a "Object Block or With Block not set" error. Any ideas?



'Create a reference to a File Reference object
Dim TempRef As IAcSmFileReference
Set TempRef = oSheetDb.GetSheetSet().GetAltPageSetups()
TempRef.SetFileName cstrOvrTemplate

'Set the default template location
oSheetDb.GetSheetSet().SetAltPageSetups TempRef


Thanks!
Michael

Ed Jobe
2008-05-23, 06:43 PM
Have you set/created oSheetDb?

mcoffman
2008-05-23, 08:13 PM
Have you set/created oSheetDb?

Yes, I have. Below is the complete function in which the offending piece of code occurs:



'Setup the Sheet Set Defaults
Private Sub SetSheetSetDefaults(oSheetDb As AcSmDatabase, strName As String, strDesc As String, Optional strNewSheetLocation As String = "", Optional strNewSheetDWTLocation As String = "", _
Optional strNewSheetDWTLayout As String = "", Optional bPromptForDWT As Boolean = False)

'Set the Name and Description for the Sheet Set
oSheetDb.GetSheetSet().SetName strName
oSheetDb.GetSheetSet().SetDesc strDesc

'Check to see if a Storage Location was provided
If strNewSheetLocation <> "" Then
'Get the Folder the Sheet Set is Stored in
Dim strSheetSetFldr As String
strSheetSetFldr = Mid(oSheetDb.GetFileName, 1, InStrRev(oSheetDb.GetFileName, "\"))

'Create a reference to a File Reference object
Dim oFileRef As IAcSmFileReference
Set oFileRef = oSheetDb.GetSheetSet().GetNewSheetLocation

'Set the default storage location based on the Sheet Sets location
oFileRef.SetFileName strSheetSetFldr

'Set the new Sheet location for the Sheet Set
oSheetDb.GetSheetSet().SetNewSheetLocation oFileRef
End If

'Set override template location.
'Create a reference to a File Reference object
Dim TempRef As IAcSmFileReference
Set TempRef = oSheetDb.GetSheetSet().GetAltPageSetups()
TempRef.SetFileName cstrOvrTemplate

'Set the default template location
oSheetDb.GetSheetSet().SetAltPageSetups TempRef

'Check to see if a Template was provided
If strNewSheetDWTLocation <> "" Then
'Add Default Template to Sheet Set
Dim oLayoutRef As AcSmAcDbLayoutReference
Set oLayoutRef = oSheetDb.GetSheetSet().GetDefDwtLayout

'Set the location of the template in the Layout Reference object
oLayoutRef.SetFileName strNewSheetDWTLocation

'Set the Layout name for the Layout Reference object
oLayoutRef.SetName strNewSheetDWTLayout

'Set the Layout Reference to the Subset
oSheetDb.GetSheetSet().SetDefDwtLayout oLayoutRef
End If

'Set the Prompt for Template option of the Subset when a new Sheet is created
oSheetDb.GetSheetSet().SetPromptForDwt bPromptForDWT

End Sub


When I get to debug mode, it's the "TempRef.SetFileName" line that is highlighted so I'm assuming it has something to do with my "Set TempRef" code.

RobertB
2008-05-27, 11:35 PM
Yes, I have. Below is the complete function in which the offending piece of code occurs:
...
When I get to debug mode, it's the "TempRef.SetFileName" line that is highlighted so I'm assuming it has something to do with my "Set TempRef" code.cstrOvrTemplate is not bound. You are writing code with Option Explict, aren't you? If you are, when you attempted to compile you would get an error because cstrOvrTemplate was not declared.

mcoffman
2008-05-28, 02:43 PM
cstrOvrTemplate is not bound. You are writing code with Option Explict, aren't you? If you are, when you attempted to compile you would get an error because cstrOvrTemplate was not declared.

Sorry, I should have clarified that. cstrOvrTemplate is a constant and dimensioned in the General Declarations area of the code. Yes, I code with Option Explicit.

MC