PDA

View Full Version : [SOLVED:] Set up pre-save name in Word 2010



sts023
11-07-2013, 07:56 AM
Hi guys....

Anyone know how to set up the first attempt at the likely "Save" or "Save As" Path and File name before the Save or Save As dialogue is presented, and without recourse to using the dialogue?

I know how to preset the values for a full blooded Save or Save As, and I think I could achieve the goal in Excel, but Word doesn't seem to have the same functionality.

I know it seems to be a silly and pointless idea, but trust me, it's a genuine need, the reasons behind which would take too long to explain.

In simple terms, I'd like to do something like

Dim strLikelyName as String
strLikelyName = "C:\SaveItHere\InThisFolder\AsName.docx"
Activedocument.FullName = strLikelyName 'I know that .Fullname is read-only

Any ideas?

macropod
11-07-2013, 03:16 PM
Hi Steve,

Does the following do what you want?

Sub Demo()
Dim strLikelyName As String
strLikelyName = "C:\SaveItHere\InThisFolder\AsName.docx"
With Application.Dialogs(wdDialogFileSaveAs)
.Name = strLikelyName
.Show
End With
End Sub
You can do whatever you like between setting strLikelyName and executing '.Show', other than changing strLikelyName or '.Name = strLikelyName', and the pre-defined name should remain.

sts023
11-08-2013, 04:07 AM
Hi again Paul (we'll have to stop meeting like this!)

I've tried a modified version of the suggested code (just removing the ".Show") in an attempt to set up the offering for the subsequent Save / Save As, but to no avail.

I suspect that what's happening is that :-
1. The Third Party Application (C4W) has control, and executes the MailMerge, then
2. I get control (via the Private Sub Document_New() module) to further modify the document (including offering a likely Save filename & path), then
3. C4W takes control and offers a new Save filename and path.

I've also tried saving the document im my code, then setting Activedocument.Saved = True, but that just results in two saves, mine and C4Ws.

Incidentally, it seems strange that Document_New is invoked AFTER the Mailmerge fields have been populated - I know this to be true 'cos I can read the values in the Mailmerge fields in the document, using code invoked from Document_New - not exactly intuitive naming, but as there's no (obvious) "Document_Pre_Mailmerge" or "Document_Post_Mailmerge" modules, I suppose we must make the best of what we have.

Back to the problem - I'm trying to get another twelve people to help me hold a seance to contact Mentor, but I'm afraid their likely response (as usual) will be "that's a massive alteration, and is therefore chargeable".
As my Company can't afford to pay twice the Nigerian National Debt for such a change, I suppose we'll just have to do the usual - change the Company to fit the Software (ugh!).
Sadly, and all too often, that's the pragmatic option.

Thanks anyway for all your help on this and other issues.
Perhaps we'll speak again....

macropod
11-08-2013, 05:06 AM
Ah, well, if you're trying to intercept someone another process, that's a whole different can of worms... I haven't encountered C4W, but you might want to consider an alternative, for example, the Many-to-One Mail Merge add-in from Doug Robbins at:
https://skydrive.live.com/?cid=5aedcb43615e886b#!/?cid=5AEDCB43615E886B!cid=5AEDCB43615E886B&id=5AEDCB43615E886B%21566
In addition to a 'Many to One' merge, the addin handles:
• Merge with Charts
• Duplex Merge
• Merge with FormFields
• Merge with Attachments
• Merge to Individual Documents
• Merge, Print and Staple

sts023
11-08-2013, 05:29 AM
Paul....

Thanks for the suggestion, but C4W (Cash4Windows) is actually a full system for managing all business contacts, scheduling financial and engineering activities, and communicating with Engineers using PDAs.

The production of documents (like Fire Alarm Certificates) is just one of many functions.

In fact, dismissive as I am of certain of Mentor's attitudes, in fact C4W was originally built to assist Intruder Alarm companies, and here at Phoenix Fire (a Fire Alarm Installation and Maintenance company) we're already guilty of a fair amount of "butchering to make it fit".

Thanks anyway....

macropod
11-08-2013, 01:37 PM
We recently had another thread where the OP was trying to do something similar (http://www.vbaexpress.com/forum/showthread.php?47888-VBA-Event-to-stop-the-server-on-a-Word-page-process-and-resume). Ultimately, you can't.

sts023
11-11-2013, 08:39 AM
Just to finalise this, I managed to stop the third party application from issuing a second save (just set
ActiveDocument.Saved = True at an appropriate point.

However, I've had to give up on updating the Path in the Footer - I ended up

saving the document (via Save or Save As),
recovering the actual name under which the document was saved,
forcing a Fields update, then
saving the document again.

Unfortunately, after all that lot, and although the document looked fine on-screen and in Print Preview, when I closed Word and C4W the re-opened the document, guess what? The path in the footer said "Document1". The obvious conclusion is that the first save worked, but subsequent ones didn't.

Having put in more diagnostics than are present on the average Mars probe, I'm fairly convinced that my code is issuing the correct commands in the correct sequence, but still it doesn't work

I've therefore had to put the Path in the document, identified with a home grown plain text "Place Marker" (I know I could have used a Bookmark, but by this time I was beginning to distrust Microsoft facilities!).

Using the same sequence of actions (though obviously modifed to cope with my Place Marker rather than a Field in a Footer) everytying worked fine. In fact I was able to remove all the fiddling about with double Saves etc, by just

issuing the dialogue SaveAs, then
picking out the name and path the User finally decided on, then
editing the Place marker, then
executing the Save.


I know this won't work for subsequent Saves: as it happens, and for other reasons, that doesn't matter.

As a solution it's workable, but intellectually disappointing, and obscenely inelegant.

Sort of like a description of Life, really....