Working through CP15-1, help
Help,
I am trying to work through the CP15-1 tutorial to get a handle on managing sheet sets using VBA. I am using Autocad 2006. I have copied the code for Adding Content to the Sheet Set File. I have tried to write a little sub procedure to launch the code from the click event of a button but I cannot seem to get the call statement right. I keep getting compile errors "missing list seperator or )" I even followed the little box that pops up to show you the syntax, I'm lost here. Here is the code I am trying to use:
Code:
Sub CreateSubset_Click()
CreateSubset(oSheetdb1 As AcSmDatabase, strName1 As String, strDesc1 As String, [strNewSheetLocation1 As String= ""], [strNewSheetDWTLocation1 As String = ""], [strNewSheetDWTLayout1 As String = ""], [bPromptForDWT1 As Boolean = False]) As AcSmSubset
End Sub
Private Function CreateSubset(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) As AcSmSubset
'' Create a Subset with the provided name and description
Set CreateSubset = oSheetDb.GetSheetSet().CreateSubset(strName, strDesc)
'' 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 = CreateSubset.GetNewSheetLocation
'' Check to see if a path was provided, if not default to the Sheet Set location
If strNewSheetLocation <> "" Then
oFileRef.SetFileName strNewSheetLocation
Else
oFileRef.SetFileName strSheetSetFldr
End If
'' Set the new sheet location for the Subset
CreateSubset.SetNewSheetLocation oFileRef
'
' Create a reference to a Layout Reference object
Dim oLayoutRef As AcSmAcDbLayoutReference
Set oLayoutRef = CreateSubset.GetDefDwtLayout
'' Check to see that a default DWT Location was passed in
If strNewSheetDWTLocation <> "" Then
'' 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
CreateSubset.SetDefDwtLayout oLayoutRef
End If
'' Set the Prompt for Template option of the Subset when a new Sheet is created
CreateSubset.SetPromptForDwt bPromptForDWT
End Function
Can someone point me in the right direction? I cannot procede until I can get past this point.
Bud
Re: Working through CP15-1, help
Code:
Sub CreateSubset_Click()
CreateSubset(oSheetdb1 As AcSmDatabase, strName1 As String, strDesc1 As String, [strNewSheetLocation1 As String= ""], [strNewSheetDWTLocation1 As String = ""], [strNewSheetDWTLayout1 As String = ""], [bPromptForDWT1 As Boolean = False]) As AcSmSubset
When you call a sub/function, you aren't defining variables, just supplying values for them. Therefore, don't use "As type" or brackets for optional parameters. The objects you are passing to the arguments have to be global or have scope within the onclick method.
1 Attachment(s)
Re: Working through CP15-1, help
Ed,
That's what I thought I set it up that way to begin with but after reading the help file notes on functions I thought that I would need the parentheses, brackets and types. the text that hovers over the line as I entered the data showed all of that.
I changed the code to the following, now I am getting an error on the first line of the function that says: "Member exists in an object module from which this object module derives" I have checked everywhere and I cannot find where else any of this line is used.
Code:
Sub CreateSubset_Click()
Dim oSheetDb2 As AcSmDatabase, _
strName2 As String, _
strDesc2 As String, _
strNewSheetLocation2 As String, _
strNewSheetDWTLocation2 As String, _
strNewSheetDWTLayout2 As String, _
bPromptForDWT2 As Boolean
Dim strCurrentDwgName2 As String
Dim strShSetFileName2 As String
CreateSubset oSheetDb2, strName2, strDesc2, strNewSheetLocation2, strNewSheetDWTLocation2, strNewSheetDWTLayout2, bPromptForDWT2
End Sub
Private Function CreateSubset(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) As AcSmSubset
'' Create a Subset with the provided name and description
Set CreateSubset = oSheetDb.GetSheetSet().CreateSubset(strName, strDesc)
'' 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 = CreateSubset.GetNewSheetLocation
'' Check to see if a path was provided, if not default to the Sheet Set location
If strNewSheetLocation <> "" Then
oFileRef.SetFileName strNewSheetLocation
Else
oFileRef.SetFileName strSheetSetFldr
End If
'' Set the new sheet location for the Subset
CreateSubset.SetNewSheetLocation oFileRef
'' Create a reference to a Layout Reference object
Dim oLayoutRef As AcSmAcDbLayoutReference
Set oLayoutRef = CreateSubset.GetDefDwtLayout
'' Check to see that a default DWT Location was passed in
If strNewSheetDWTLocation <> "" Then
'' 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
CreateSubset.SetDefDwtLayout oLayoutRef
End If
'' Set the Prompt for Template option of the Subset when a new Sheet is created
CreateSubset.SetPromptForDwt bPromptForDWT
End Function
Re: Working through CP15-1, help
Quote:
Originally Posted by
buddy.brooks
the text that hovers over the line as I entered the data showed all of that.
The signature of the sub you are calling is displayed so that you will know how many arguments are required and what data type they are. If an argument calls for a string type, enter a string in double quotes, enter the name of a variable containing a string, or a function that returns a string.
Quote:
I changed the code to the following, now I am getting an error on the first line of the function that says: "Member exists in an object module from which this object module derives" I have checked everywhere and I cannot find where else any of this line is used.
There are 7 variables defined in the signature, have you searched for all 7?