Greatheights
New Member
- Joined
- Mar 14, 2013
- Messages
- 31
Good day, all,
I'm trying to create and set serveral custom document properties on documents. Once uploaded to a Sharepoing library, these properties are used to sort the documents and move them through a workflow. My object is to allow another user to input the values using a user form, so that the properties are already there when the document is added to Sharepoint.
All the variables I'm using a Public in the module that call this DocProps Sub, and are set through a user form that's in a different Sub.
When my bigger macro calls DocProps, I'm getting an "object required" run-time error on the first line of code.
<code>
Sub DocProps()
'Adds the Line of Business Property and defines it as the pLine variable
Wb.CustomDocumentProperties.Add _
Name:="Line of Business", _
LinkToContent:=False, _
Type:=DocType, _
Value:=pLine
'adds the Company name property and defines it as the pCompany variable
Wb.CustomDocumentProperties.Add _
Name:="Company Name", _
LinkToContent:=False, _
Type:=DocType, _
Value:=pCompany
'adds the Year property and defines it as the pYear variable
Wb.CustomDocumentProperties.Add _
Name:="Year", _
LinkToContent:=False, _
Type:=DocType, _
Value:=pYear
'adds the Time Period property and defines it as the pPeriod variable
Wb.CustomDocumentProperties.Add _
Name:="Time Period", _
LinkToContent:=False, _
Type:=DocType, _
Value:=pPeriod
'adds the Date Loaded property and defines it as the pLoaded variable
Wb.CustomDocumentProperties.Add _
Name:="Line of Business", _
LinkToContent:=False, _
Type:=DocType, _
Value:=pLoaded
'adds Number of Policies property and defines it as the value from cell B6
Wb.CustomDocumentProperties.Add _
Name:="Number of Policies", _
LinkToContent:=False, _
Type:=DocType, _
Value:=Range("B6").Value
End Sub
</code>
This is my first time trying to pass variables through to custom properties like this, so I'm guessing my syntax is just wrong, but I've been unable to find any tips by searching. The only possibility I've found is that I should be using "ContentTypeProperty" instead of "CustomDocumentProperties" by I tried swapping that out and got the same result.
This is all being done in Excel 2007
Thanks for the help.
I'm trying to create and set serveral custom document properties on documents. Once uploaded to a Sharepoing library, these properties are used to sort the documents and move them through a workflow. My object is to allow another user to input the values using a user form, so that the properties are already there when the document is added to Sharepoint.
All the variables I'm using a Public in the module that call this DocProps Sub, and are set through a user form that's in a different Sub.
When my bigger macro calls DocProps, I'm getting an "object required" run-time error on the first line of code.
<code>
Sub DocProps()
'Adds the Line of Business Property and defines it as the pLine variable
Wb.CustomDocumentProperties.Add _
Name:="Line of Business", _
LinkToContent:=False, _
Type:=DocType, _
Value:=pLine
'adds the Company name property and defines it as the pCompany variable
Wb.CustomDocumentProperties.Add _
Name:="Company Name", _
LinkToContent:=False, _
Type:=DocType, _
Value:=pCompany
'adds the Year property and defines it as the pYear variable
Wb.CustomDocumentProperties.Add _
Name:="Year", _
LinkToContent:=False, _
Type:=DocType, _
Value:=pYear
'adds the Time Period property and defines it as the pPeriod variable
Wb.CustomDocumentProperties.Add _
Name:="Time Period", _
LinkToContent:=False, _
Type:=DocType, _
Value:=pPeriod
'adds the Date Loaded property and defines it as the pLoaded variable
Wb.CustomDocumentProperties.Add _
Name:="Line of Business", _
LinkToContent:=False, _
Type:=DocType, _
Value:=pLoaded
'adds Number of Policies property and defines it as the value from cell B6
Wb.CustomDocumentProperties.Add _
Name:="Number of Policies", _
LinkToContent:=False, _
Type:=DocType, _
Value:=Range("B6").Value
End Sub
</code>
This is my first time trying to pass variables through to custom properties like this, so I'm guessing my syntax is just wrong, but I've been unable to find any tips by searching. The only possibility I've found is that I should be using "ContentTypeProperty" instead of "CustomDocumentProperties" by I tried swapping that out and got the same result.
This is all being done in Excel 2007
Thanks for the help.