changing the propeties by macro

×

×ליר×

Hello,

I use a lot in the document's properties in the Word.
(File > properties).

I would like to create a macro command that writes in the documents'
properties, under the detail of 'title', the following line:

"Discussion in a <name of the file's folder>, class number <file name>

For instance: if my file name is 101, and it's placed in the folder named
"business", the title (in the properties) will be:

Discussion in a business, class number 01


This is, I guess, such a sophisticated program, so I would be happy to have
specifically answer.


Thanks a lot!
 
J

Jean-Guy Marcil

××œ×™×¨× said:
Hello,

I use a lot in the document's properties in the Word.
(File > properties).

I would like to create a macro command that writes in the documents'
properties, under the detail of 'title', the following line:

"Discussion in a <name of the file's folder>, class number <file name>

For instance: if my file name is 101, and it's placed in the folder named
"business", the title (in the properties) will be:

Discussion in a business, class number 01


This is, I guess, such a sophisticated program, so I would be happy to have
specifically answer.

Try this:

Const strDisc1 As String = "Discussion in a """
Const strDisc2 As String = """, class number """
Const strDisc3 As String = """"
Dim strFolder As String
Dim strName As String
Dim varFull As Variant

If ActiveDocument.Path = "" Then
MsgBox "Save the document before using this function.", _
vbExclamation, "Save First"
Exit Sub
End If

varFull = Split(ActiveDocument.FullName, "\")
strName = varFull(UBound(varFull))
strName = Left(strName, Len(strName) - 4)
strFolder = varFull(UBound(varFull) - 1)

ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle) = _
strDisc1 & strFolder & strDisc2 & strName & strDisc3
 
F

fumei via OfficeKB.com

Or a very similar version:

Dim strDisc1 As String
Dim strDisc2 As String
Dim filefolder As String
Dim filename As String

strDisc1 = "Discussion in a "
strDisc2 = ", class number "

If ActiveDocument.Path = "" Then
MsgBox "Save the document before using this function.", _
vbExclamation, "Save First"
Exit Sub
Else
filefolder = ActiveDocument.Path & "\"
filename = Left(ActiveDocument.Name, _
Len(ActiveDocument.Name) - 4)
End If

ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle) = _
strDisc1 & filefolder & strDisc2 & filename

Jean-Guy Marcil said:
[quoted text clipped - 13 lines]
This is, I guess, such a sophisticated program, so I would be happy to have
specifically answer.

Try this:

Const strDisc1 As String = "Discussion in a """
Const strDisc2 As String = """, class number """
Const strDisc3 As String = """"
Dim strFolder As String
Dim strName As String
Dim varFull As Variant

If ActiveDocument.Path = "" Then
MsgBox "Save the document before using this function.", _
vbExclamation, "Save First"
Exit Sub
End If

varFull = Split(ActiveDocument.FullName, "\")
strName = varFull(UBound(varFull))
strName = Left(strName, Len(strName) - 4)
strFolder = varFull(UBound(varFull) - 1)

ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle) = _
strDisc1 & strFolder & strDisc2 & strName & strDisc3
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top