Set default filename from DIP values?

 

I am trying to get Word to pre-populate a filename from several document properties specified by the user in the DIP. These documents are created from a template.

So, in the DIP, I have five fields:

  • the standard Title field
  • custom field 1
  • custom field 2
  • custom field 3
  • custom field 4

Ideally, the Title column would concatenate the four custom fields, but it doesn't seem like that's doable. I'd settle for the default filename populating like this:

 

custom field 1 - custom field 2 - custom field 3 - custom field 4.docx

 

I can kind of get this working by inserting the doc properties consecutively as the first block of content in the document, but that creates a runon:

 

custom field 1 custom field 2 custom field 3 custom field 4.docx

 

It seems the hyphens act as a sort of "full stop" for populating the filename. If I include hyphens between the doc property fields, i only get:

custom field 1.docx

 

These documents will be saved to a SharePoint library (and in fact are created using a content type in SharePoint, if that makes any difference). I suppose I could add an event handler to assign the filename, but I'd prefer to avoid that if at all possible.

Answer
Answer
Thanks.

I looked at this again:

 

             strfName = .ContentTypeProperties("FIS_x0200_Application").Value & Chr(45) & _
                        .ContentTypeProperties("Subtype").Value & Chr(45) & _
                        .ContentTypeProperties("Ticket_x0200_Number").Value & Chr(45) & _
                        .ContentTypeProperties("Subject_x0200_Line").Value


I'd missed that you had tried the "UI version of the labels" as well. The names in the VBA code do have to be exact matches for the ones you would find using the code I provided to list the names the "display versions" of the field. For example, you may need "Subtype" not "subtype", but assuming that you already got that right, there must be another factor.

At this point I would probably try to break the VBA down into separate statements to see if a particular name causes a problem. e.g.

strfName = .ContentTypeProperties("FIS_x0200_Application").Value & Chr(45) 

strfName = strfName & .ContentTypeProperties("Subtype").Value & Chr(45) 


and so on. 


I also wonder whether any kind of "null value" would cause a problem, but since these values are all coming from XML I think the worst you could get is that the value is an empty string, and that does not appear to cause a problem.


Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated February 25, 2020 Views 2,635 Applies to: