dellehurley
Board Regular
- Joined
- Sep 26, 2009
- Messages
- 171
- Office Version
- 365
- Platform
- Windows
Hi
I have a userform which I use to move and rename files, populate an associated database and hopefully update the documents properties.
I have all the first parts working but I cannot get the documents properties sub to work. I feel like I have tried what feels thousands of variations.
Additional Info- all the files are jpg or pdfs. They are all moved and stored in the same folder which is where the excel database file is saved too. All the issues are in regards to objects not being declared.
the current error is runtime 91 -object variable or with block variable not set.
This is what I have so far
I appreciate any help or suggestions.
Thanks
Dannielle
I have a userform which I use to move and rename files, populate an associated database and hopefully update the documents properties.
I have all the first parts working but I cannot get the documents properties sub to work. I feel like I have tried what feels thousands of variations.
Additional Info- all the files are jpg or pdfs. They are all moved and stored in the same folder which is where the excel database file is saved too. All the issues are in regards to objects not being declared.
the current error is runtime 91 -object variable or with block variable not set.
This is what I have so far
VBA Code:
Dim fileName, folderName, newName As Variant
Dim NewNameObj As Image 'this was my most recent change
Dim EventDate As DocumentProperty
Dim Tags As DocumentProperty
Dim Description As DocumentProperty
Dim Evt, EvtDt, Tgs, Desc As String
folderName = ThisWorkbook.Path & "\"
fileName = frmNewEntry.txtFileName.Value
newName = folderName & fileName
'Set NewNameObj = newName.CustomDocumentProperties
Evt = frmNewEntry.cmbEvent.Value 'or ThisWorkbook.Sheets("Database").Range("D2").Value
Desc = frmNewEntry.txtDescription.Value 'or ThisWorkbook.Sheets("Database").Range("I2").Value
Tgs = ThisWorkbook.Sheets("Database").Range("J2").Value
EvtDt = frmNewEntry.txtDate.Value 'or ThisWorkbook.Sheets("Database").Range("H2").Value 'NB. I wish to keep this as a string even though it is a date as the info is not always a full date, it is often an estimate eg. Abt 1940
With NewNameObj.CustomDocumentProperties
.Add Name:="nEvent", LinkToContent:=False, Type:=msoPropertyTypeString, Value:=Evt 'BTW -Link to content Honestly I'm not sure what this is so it may be incorrect
.Add Name:="Description", LinkToContent:=False, Type:=msoPropertyTypeString, Value:=Desc 'Type names in an effort to try something else.
.Add Name:="Tags", LinkToContent:=False, Type:=msoPropertyTypeString, Value:=Tgs
.Add Name:="EventDate", LinkToContent:=False, Type:=msoPropertyTypeString, Value:=EvtDt
End With
I appreciate any help or suggestions.
Thanks
Dannielle