Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Displaying only part of a filename
I'm trying to find a way to use the Filename field to display only part of
the filename. It needs to be dynamic so if the document name changes, the field w/automatically update. I'm thinking something to the effect of inserting a field then {Mid$({FileName},7,6)}. When I toggle the code the whole thing disappears. |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Displaying only part of a filename
On Tue, 17 Jan 2006 14:26:03 -0800, "Lori"
wrote: I'm trying to find a way to use the Filename field to display only part of the filename. It needs to be dynamic so if the document name changes, the field w/automatically update. I'm thinking something to the effect of inserting a field then {Mid$({FileName},7,6)}. When I toggle the code the whole thing disappears. Sorry, there's no way to do this without actually writing a macro and setting up some way to run it. The field isn't capable of that kind of manipulation. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Displaying only part of a filename
As Jay says, you can't do this with a field. The macro equivalent would be
Sub InsertFnameOnly() Dim pPathname As String With ActiveDocument If Not .Saved Then .Save End If pPathname = Mid$(.Name, 7, 6) End With Selection.TypeText pPathname End Sub However this must be peculiar to the one document. Are you simply tryting to remove the filename extension? If so Sub InsertFnameOnly() Dim pPathname As String With ActiveDocument If Not .Saved Then .Save End If pPathname = Left$(.Name, (Len(.Name) - 4)) End With Selection.TypeText pPathname End Sub would be nearer the mark. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Lori wrote: I'm trying to find a way to use the Filename field to display only part of the filename. It needs to be dynamic so if the document name changes, the field w/automatically update. I'm thinking something to the effect of inserting a field then {Mid$({FileName},7,6)}. When I toggle the code the whole thing disappears. |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Displaying only part of a filename
Graham~
Thanks. We lots of ways of linking it to the save function, however we need to avoid that. We have a document management system that includes libraryname - docnumb.version - documentreallylongnamebecauseouruserslikethem All I want to snag is the docnumb.version, the application has way of placing this in statically, or a simple text, however we need it to be dynamic so when on the occassions when they do include the document number and create a new version or new document that number changes. AND they don't always want the number which is why we can't link it with the save as feature. ~Lori "Graham Mayor" wrote: As Jay says, you can't do this with a field. The macro equivalent would be Sub InsertFnameOnly() Dim pPathname As String With ActiveDocument If Not .Saved Then .Save End If pPathname = Mid$(.Name, 7, 6) End With Selection.TypeText pPathname End Sub However this must be peculiar to the one document. Are you simply tryting to remove the filename extension? If so Sub InsertFnameOnly() Dim pPathname As String With ActiveDocument If Not .Saved Then .Save End If pPathname = Left$(.Name, (Len(.Name) - 4)) End With Selection.TypeText pPathname End Sub would be nearer the mark. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Lori wrote: I'm trying to find a way to use the Filename field to display only part of the filename. It needs to be dynamic so if the document name changes, the field w/automatically update. I'm thinking something to the effect of inserting a field then {Mid$({FileName},7,6)}. When I toggle the code the whole thing disappears. |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Displaying only part of a filename
Hi Lori,
I'm not sure what you're saying with "the application has way of placing this in statically, or a simple text". Do you mean that the doc management application can insert text in the body of the document, as opposed to (or in addition to) setting the document's file name? Can it put that text in a specific location in the document, such as inserting it as a new first paragraph? If so, write a macro to grab the necessary data from that text and place it in a custom document property, and insert a DocProperty field in the footer or wherever you want it. In cases where the user doesn't want the number to appear, they can delete the DocProperty field while still leaving the custom property in place (it would still be visible in the File Properties Custom dialog). -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. Lori wrote: Graham~ Thanks. We lots of ways of linking it to the save function, however we need to avoid that. We have a document management system that includes libraryname - docnumb.version - documentreallylongnamebecauseouruserslikethem All I want to snag is the docnumb.version, the application has way of placing this in statically, or a simple text, however we need it to be dynamic so when on the occassions when they do include the document number and create a new version or new document that number changes. AND they don't always want the number which is why we can't link it with the save as feature. ~Lori "Graham Mayor" wrote: As Jay says, you can't do this with a field. The macro equivalent would be Sub InsertFnameOnly() Dim pPathname As String With ActiveDocument If Not .Saved Then .Save End If pPathname = Mid$(.Name, 7, 6) End With Selection.TypeText pPathname End Sub However this must be peculiar to the one document. Are you simply tryting to remove the filename extension? If so Sub InsertFnameOnly() Dim pPathname As String With ActiveDocument If Not .Saved Then .Save End If pPathname = Left$(.Name, (Len(.Name) - 4)) End With Selection.TypeText pPathname End Sub would be nearer the mark. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Lori wrote: I'm trying to find a way to use the Filename field to display only part of the filename. It needs to be dynamic so if the document name changes, the field w/automatically update. I'm thinking something to the effect of inserting a field then {Mid$({FileName},7,6)}. When I toggle the code the whole thing disappears. |
#6
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Displaying only part of a filename
Jay~
Thank you. Yes different ways is what I'm looking for. I'm slowing learning VB the hard way. I will check into this, it's a good idea my only concern is the users would have to keep updating the custom property, which is the same as running an existing macro that puts the Document Number into the footer. I'm trying to find a way that once the feild is inserted, the user doesn't have to do anything again, it will automatically update. The other issue is this application replaces the Word FileProperties w/it's own Properties (ie Profile) screen. I was hoping there was simple way to manipulate the {FILENAME} feild by nesting it inside another field, such as {Mid$({FILENAME},7,6)}. But that just disappears when I try it. ~Lori "Jay Freedman" wrote: Hi Lori, I'm not sure what you're saying with "the application has way of placing this in statically, or a simple text". Do you mean that the doc management application can insert text in the body of the document, as opposed to (or in addition to) setting the document's file name? Can it put that text in a specific location in the document, such as inserting it as a new first paragraph? If so, write a macro to grab the necessary data from that text and place it in a custom document property, and insert a DocProperty field in the footer or wherever you want it. In cases where the user doesn't want the number to appear, they can delete the DocProperty field while still leaving the custom property in place (it would still be visible in the File Properties Custom dialog). -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. Lori wrote: Graham~ Thanks. We lots of ways of linking it to the save function, however we need to avoid that. We have a document management system that includes libraryname - docnumb.version - documentreallylongnamebecauseouruserslikethem All I want to snag is the docnumb.version, the application has way of placing this in statically, or a simple text, however we need it to be dynamic so when on the occassions when they do include the document number and create a new version or new document that number changes. AND they don't always want the number which is why we can't link it with the save as feature. ~Lori "Graham Mayor" wrote: As Jay says, you can't do this with a field. The macro equivalent would be Sub InsertFnameOnly() Dim pPathname As String With ActiveDocument If Not .Saved Then .Save End If pPathname = Mid$(.Name, 7, 6) End With Selection.TypeText pPathname End Sub However this must be peculiar to the one document. Are you simply tryting to remove the filename extension? If so Sub InsertFnameOnly() Dim pPathname As String With ActiveDocument If Not .Saved Then .Save End If pPathname = Left$(.Name, (Len(.Name) - 4)) End With Selection.TypeText pPathname End Sub would be nearer the mark. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Lori wrote: I'm trying to find a way to use the Filename field to display only part of the filename. It needs to be dynamic so if the document name changes, the field w/automatically update. I'm thinking something to the effect of inserting a field then {Mid$({FileName},7,6)}. When I toggle the code the whole thing disappears. |
#7
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Displaying only part of a filename
If you write a macro and name it FileSaveAs, it will automatically
intercept the built-in Save As command (see http://www.word.mvps.org/FAQs/Macros...tSavePrint.htm). The macro should: - Display the Save As dialog to let the user (or the management app) specify the new file name. In VBA, the .Display method of the dialog object displays the dialog box but doesn't actually save the document, so the macro just gets the path and name in a variable. - Change the value of the custom document property if necessary. - Update the DocProperty field in the footer. - Use the .Save method to do the actual save with the new name. A full discussion of this, if you need more direction, should be moved into the microsoft.public.word.vba.beginners newsgroup. You can forget about running VBA code inside a field -- it just doesn't work. The closest you can get is a MacroButton field, which runs a macro when you double-click it. It still isn't automatic. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. On Wed, 18 Jan 2006 13:39:02 -0800, "Lori" wrote: Jay~ Thank you. Yes different ways is what I'm looking for. I'm slowing learning VB the hard way. I will check into this, it's a good idea my only concern is the users would have to keep updating the custom property, which is the same as running an existing macro that puts the Document Number into the footer. I'm trying to find a way that once the feild is inserted, the user doesn't have to do anything again, it will automatically update. The other issue is this application replaces the Word FileProperties w/it's own Properties (ie Profile) screen. I was hoping there was simple way to manipulate the {FILENAME} feild by nesting it inside another field, such as {Mid$({FILENAME},7,6)}. But that just disappears when I try it. ~Lori "Jay Freedman" wrote: Hi Lori, I'm not sure what you're saying with "the application has way of placing this in statically, or a simple text". Do you mean that the doc management application can insert text in the body of the document, as opposed to (or in addition to) setting the document's file name? Can it put that text in a specific location in the document, such as inserting it as a new first paragraph? If so, write a macro to grab the necessary data from that text and place it in a custom document property, and insert a DocProperty field in the footer or wherever you want it. In cases where the user doesn't want the number to appear, they can delete the DocProperty field while still leaving the custom property in place (it would still be visible in the File Properties Custom dialog). -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. Lori wrote: Graham~ Thanks. We lots of ways of linking it to the save function, however we need to avoid that. We have a document management system that includes libraryname - docnumb.version - documentreallylongnamebecauseouruserslikethem All I want to snag is the docnumb.version, the application has way of placing this in statically, or a simple text, however we need it to be dynamic so when on the occassions when they do include the document number and create a new version or new document that number changes. AND they don't always want the number which is why we can't link it with the save as feature. ~Lori "Graham Mayor" wrote: As Jay says, you can't do this with a field. The macro equivalent would be Sub InsertFnameOnly() Dim pPathname As String With ActiveDocument If Not .Saved Then .Save End If pPathname = Mid$(.Name, 7, 6) End With Selection.TypeText pPathname End Sub However this must be peculiar to the one document. Are you simply tryting to remove the filename extension? If so Sub InsertFnameOnly() Dim pPathname As String With ActiveDocument If Not .Saved Then .Save End If pPathname = Left$(.Name, (Len(.Name) - 4)) End With Selection.TypeText pPathname End Sub would be nearer the mark. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Lori wrote: I'm trying to find a way to use the Filename field to display only part of the filename. It needs to be dynamic so if the document name changes, the field w/automatically update. I'm thinking something to the effect of inserting a field then {Mid$({FileName},7,6)}. When I toggle the code the whole thing disappears. |
#8
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Displaying only part of a filename
You can't do this with a field - Jay has offered some alternative
suggestions, but the first of the macros I posted earlier will put the part of the filename you want at the cursor. http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Lori wrote: Graham~ Thanks. We lots of ways of linking it to the save function, however we need to avoid that. We have a document management system that includes libraryname - docnumb.version - documentreallylongnamebecauseouruserslikethem All I want to snag is the docnumb.version, the application has way of placing this in statically, or a simple text, however we need it to be dynamic so when on the occassions when they do include the document number and create a new version or new document that number changes. AND they don't always want the number which is why we can't link it with the save as feature. ~Lori "Graham Mayor" wrote: As Jay says, you can't do this with a field. The macro equivalent would be Sub InsertFnameOnly() Dim pPathname As String With ActiveDocument If Not .Saved Then .Save End If pPathname = Mid$(.Name, 7, 6) End With Selection.TypeText pPathname End Sub However this must be peculiar to the one document. Are you simply tryting to remove the filename extension? If so Sub InsertFnameOnly() Dim pPathname As String With ActiveDocument If Not .Saved Then .Save End If pPathname = Left$(.Name, (Len(.Name) - 4)) End With Selection.TypeText pPathname End Sub would be nearer the mark. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Lori wrote: I'm trying to find a way to use the Filename field to display only part of the filename. It needs to be dynamic so if the document name changes, the field w/automatically update. I'm thinking something to the effect of inserting a field then {Mid$({FileName},7,6)}. When I toggle the code the whole thing disappears. |
#9
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Displaying only part of a filename
Jay~
I can not link it to the Save or Save As feature since that would effect all docs created or modified, I only need it for certain docs. ~Lori "Jay Freedman" wrote: If you write a macro and name it FileSaveAs, it will automatically intercept the built-in Save As command (see http://www.word.mvps.org/FAQs/Macros...tSavePrint.htm). The macro should: - Display the Save As dialog to let the user (or the management app) specify the new file name. In VBA, the .Display method of the dialog object displays the dialog box but doesn't actually save the document, so the macro just gets the path and name in a variable. - Change the value of the custom document property if necessary. - Update the DocProperty field in the footer. - Use the .Save method to do the actual save with the new name. A full discussion of this, if you need more direction, should be moved into the microsoft.public.word.vba.beginners newsgroup. You can forget about running VBA code inside a field -- it just doesn't work. The closest you can get is a MacroButton field, which runs a macro when you double-click it. It still isn't automatic. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. On Wed, 18 Jan 2006 13:39:02 -0800, "Lori" wrote: Jay~ Thank you. Yes different ways is what I'm looking for. I'm slowing learning VB the hard way. I will check into this, it's a good idea my only concern is the users would have to keep updating the custom property, which is the same as running an existing macro that puts the Document Number into the footer. I'm trying to find a way that once the feild is inserted, the user doesn't have to do anything again, it will automatically update. The other issue is this application replaces the Word FileProperties w/it's own Properties (ie Profile) screen. I was hoping there was simple way to manipulate the {FILENAME} feild by nesting it inside another field, such as {Mid$({FILENAME},7,6)}. But that just disappears when I try it. ~Lori "Jay Freedman" wrote: Hi Lori, I'm not sure what you're saying with "the application has way of placing this in statically, or a simple text". Do you mean that the doc management application can insert text in the body of the document, as opposed to (or in addition to) setting the document's file name? Can it put that text in a specific location in the document, such as inserting it as a new first paragraph? If so, write a macro to grab the necessary data from that text and place it in a custom document property, and insert a DocProperty field in the footer or wherever you want it. In cases where the user doesn't want the number to appear, they can delete the DocProperty field while still leaving the custom property in place (it would still be visible in the File Properties Custom dialog). -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. Lori wrote: Graham~ Thanks. We lots of ways of linking it to the save function, however we need to avoid that. We have a document management system that includes libraryname - docnumb.version - documentreallylongnamebecauseouruserslikethem All I want to snag is the docnumb.version, the application has way of placing this in statically, or a simple text, however we need it to be dynamic so when on the occassions when they do include the document number and create a new version or new document that number changes. AND they don't always want the number which is why we can't link it with the save as feature. ~Lori "Graham Mayor" wrote: As Jay says, you can't do this with a field. The macro equivalent would be Sub InsertFnameOnly() Dim pPathname As String With ActiveDocument If Not .Saved Then .Save End If pPathname = Mid$(.Name, 7, 6) End With Selection.TypeText pPathname End Sub However this must be peculiar to the one document. Are you simply tryting to remove the filename extension? If so Sub InsertFnameOnly() Dim pPathname As String With ActiveDocument If Not .Saved Then .Save End If pPathname = Left$(.Name, (Len(.Name) - 4)) End With Selection.TypeText pPathname End Sub would be nearer the mark. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Lori wrote: I'm trying to find a way to use the Filename field to display only part of the filename. It needs to be dynamic so if the document name changes, the field w/automatically update. I'm thinking something to the effect of inserting a field then {Mid$({FileName},7,6)}. When I toggle the code the whole thing disappears. |
#10
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Displaying only part of a filename
Is there any way the macro could automatically identify *which* documents it
should process? Is there some identifying characteristic of those documents? The easiest case is when all the documents that need processing are based on one template (or a small set of templates), and all the documents that don't need processing are based on other templates. Then you can put the FileSaveAs macro only the the specific template(s), and it will run only in documents based on that template. If that doesn't suit your situation, it's possible to build the macro to look at whatever identifies the "right" documents and ignore all the "wrong" documents -- but I can't tell you what that code might be until you can state, simply and succinctly, what distinguishes "right" from "wrong". If it's up to the user to decide, then the macro would have to display a Yes/No message box. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. Lori wrote: Jay~ I can not link it to the Save or Save As feature since that would effect all docs created or modified, I only need it for certain docs. ~Lori "Jay Freedman" wrote: If you write a macro and name it FileSaveAs, it will automatically intercept the built-in Save As command (see http://www.word.mvps.org/FAQs/Macros...tSavePrint.htm). The macro should: - Display the Save As dialog to let the user (or the management app) specify the new file name. In VBA, the .Display method of the dialog object displays the dialog box but doesn't actually save the document, so the macro just gets the path and name in a variable. - Change the value of the custom document property if necessary. - Update the DocProperty field in the footer. - Use the .Save method to do the actual save with the new name. A full discussion of this, if you need more direction, should be moved into the microsoft.public.word.vba.beginners newsgroup. You can forget about running VBA code inside a field -- it just doesn't work. The closest you can get is a MacroButton field, which runs a macro when you double-click it. It still isn't automatic. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. On Wed, 18 Jan 2006 13:39:02 -0800, "Lori" wrote: Jay~ Thank you. Yes different ways is what I'm looking for. I'm slowing learning VB the hard way. I will check into this, it's a good idea my only concern is the users would have to keep updating the custom property, which is the same as running an existing macro that puts the Document Number into the footer. I'm trying to find a way that once the feild is inserted, the user doesn't have to do anything again, it will automatically update. The other issue is this application replaces the Word FileProperties w/it's own Properties (ie Profile) screen. I was hoping there was simple way to manipulate the {FILENAME} feild by nesting it inside another field, such as {Mid$({FILENAME},7,6)}. But that just disappears when I try it. ~Lori "Jay Freedman" wrote: Hi Lori, I'm not sure what you're saying with "the application has way of placing this in statically, or a simple text". Do you mean that the doc management application can insert text in the body of the document, as opposed to (or in addition to) setting the document's file name? Can it put that text in a specific location in the document, such as inserting it as a new first paragraph? If so, write a macro to grab the necessary data from that text and place it in a custom document property, and insert a DocProperty field in the footer or wherever you want it. In cases where the user doesn't want the number to appear, they can delete the DocProperty field while still leaving the custom property in place (it would still be visible in the File Properties Custom dialog). -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. Lori wrote: Graham~ Thanks. We lots of ways of linking it to the save function, however we need to avoid that. We have a document management system that includes libraryname - docnumb.version - documentreallylongnamebecauseouruserslikethem All I want to snag is the docnumb.version, the application has way of placing this in statically, or a simple text, however we need it to be dynamic so when on the occassions when they do include the document number and create a new version or new document that number changes. AND they don't always want the number which is why we can't link it with the save as feature. ~Lori "Graham Mayor" wrote: As Jay says, you can't do this with a field. The macro equivalent would be Sub InsertFnameOnly() Dim pPathname As String With ActiveDocument If Not .Saved Then .Save End If pPathname = Mid$(.Name, 7, 6) End With Selection.TypeText pPathname End Sub However this must be peculiar to the one document. Are you simply tryting to remove the filename extension? If so Sub InsertFnameOnly() Dim pPathname As String With ActiveDocument If Not .Saved Then .Save End If pPathname = Left$(.Name, (Len(.Name) - 4)) End With Selection.TypeText pPathname End Sub would be nearer the mark. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Lori wrote: I'm trying to find a way to use the Filename field to display only part of the filename. It needs to be dynamic so if the document name changes, the field w/automatically update. I'm thinking something to the effect of inserting a field then {Mid$({FileName},7,6)}. When I toggle the code the whole thing disappears. |
#11
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Displaying only part of a filename
Jay~
User whim. About 1/2 the docs will contain the document number, the rest won't. At some point, and not always on the first version, someone will think it's Jim-Dandy-Nice to have the doc.ver number so they can easily find it again if they are reviewing a printed copy. Once the doc.ver number is inserted, it's updated through it's various versions, subversion (and for some reason complete document number change) until the document is ready to be published (ie sent to client/customer or third party) when they will remove the docnumber. Since some of these docs can have up to 10-15 versions (not including multiple sub-version and whole-sale docnumber changes) they are getting cranking about manually updating the number. I've been on several lists, dealing w/our docmgmt sw company, and random websurfing and am coming to the conclusion it can't be done and must now move on to my next project of figuring out how to count dates in four different Access tables and get them to display nicely on the main form. Thanks for trying though. ~Lori "Jay Freedman" wrote: Is there any way the macro could automatically identify *which* documents it should process? Is there some identifying characteristic of those documents? The easiest case is when all the documents that need processing are based on one template (or a small set of templates), and all the documents that don't need processing are based on other templates. Then you can put the FileSaveAs macro only the the specific template(s), and it will run only in documents based on that template. If that doesn't suit your situation, it's possible to build the macro to look at whatever identifies the "right" documents and ignore all the "wrong" documents -- but I can't tell you what that code might be until you can state, simply and succinctly, what distinguishes "right" from "wrong". If it's up to the user to decide, then the macro would have to display a Yes/No message box. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. Lori wrote: Jay~ I can not link it to the Save or Save As feature since that would effect all docs created or modified, I only need it for certain docs. ~Lori "Jay Freedman" wrote: If you write a macro and name it FileSaveAs, it will automatically intercept the built-in Save As command (see http://www.word.mvps.org/FAQs/Macros...tSavePrint.htm). The macro should: - Display the Save As dialog to let the user (or the management app) specify the new file name. In VBA, the .Display method of the dialog object displays the dialog box but doesn't actually save the document, so the macro just gets the path and name in a variable. - Change the value of the custom document property if necessary. - Update the DocProperty field in the footer. - Use the .Save method to do the actual save with the new name. A full discussion of this, if you need more direction, should be moved into the microsoft.public.word.vba.beginners newsgroup. You can forget about running VBA code inside a field -- it just doesn't work. The closest you can get is a MacroButton field, which runs a macro when you double-click it. It still isn't automatic. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. On Wed, 18 Jan 2006 13:39:02 -0800, "Lori" wrote: Jay~ Thank you. Yes different ways is what I'm looking for. I'm slowing learning VB the hard way. I will check into this, it's a good idea my only concern is the users would have to keep updating the custom property, which is the same as running an existing macro that puts the Document Number into the footer. I'm trying to find a way that once the feild is inserted, the user doesn't have to do anything again, it will automatically update. The other issue is this application replaces the Word FileProperties w/it's own Properties (ie Profile) screen. I was hoping there was simple way to manipulate the {FILENAME} feild by nesting it inside another field, such as {Mid$({FILENAME},7,6)}. But that just disappears when I try it. ~Lori "Jay Freedman" wrote: Hi Lori, I'm not sure what you're saying with "the application has way of placing this in statically, or a simple text". Do you mean that the doc management application can insert text in the body of the document, as opposed to (or in addition to) setting the document's file name? Can it put that text in a specific location in the document, such as inserting it as a new first paragraph? If so, write a macro to grab the necessary data from that text and place it in a custom document property, and insert a DocProperty field in the footer or wherever you want it. In cases where the user doesn't want the number to appear, they can delete the DocProperty field while still leaving the custom property in place (it would still be visible in the File Properties Custom dialog). -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. Lori wrote: Graham~ Thanks. We lots of ways of linking it to the save function, however we need to avoid that. We have a document management system that includes libraryname - docnumb.version - documentreallylongnamebecauseouruserslikethem All I want to snag is the docnumb.version, the application has way of placing this in statically, or a simple text, however we need it to be dynamic so when on the occassions when they do include the document number and create a new version or new document that number changes. AND they don't always want the number which is why we can't link it with the save as feature. ~Lori "Graham Mayor" wrote: As Jay says, you can't do this with a field. The macro equivalent would be Sub InsertFnameOnly() Dim pPathname As String With ActiveDocument If Not .Saved Then .Save End If pPathname = Mid$(.Name, 7, 6) End With Selection.TypeText pPathname End Sub However this must be peculiar to the one document. Are you simply tryting to remove the filename extension? If so Sub InsertFnameOnly() Dim pPathname As String With ActiveDocument If Not .Saved Then .Save End If pPathname = Left$(.Name, (Len(.Name) - 4)) End With Selection.TypeText pPathname End Sub would be nearer the mark. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Lori wrote: I'm trying to find a way to use the Filename field to display only part of the filename. It needs to be dynamic so if the document name changes, the field w/automatically update. I'm thinking something to the effect of inserting a field then {Mid$({FileName},7,6)}. When I toggle the code the whole thing disappears. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Word 97 filename length limited | Microsoft Word Help | |||
Stop "FILENAME" from printing in header and footer via Autotext | Microsoft Word Help | |||
Having problems printing AutoText (filename) in MS Word. | Microsoft Word Help | |||
Filename in topptext in normal.dot doesn´t update | Microsoft Word Help | |||
Filename field in header - automatically update? | Microsoft Word Help |