
Using Clipboard Contents to Develop Filename and Save to Desktop
Still can't see why the Clipboard needs to be utilized ....
I never use the clipboard for purposes similar to yr quest.
Why? Users can empty the clipboard easily ... let's put it mildly:
yr work will be in vain then :(
1)
If y're composing the file name during run/execution time of
the macro, a string variable can hold the value.
At the end of this macro, bring up the SaveAs dialog like indicated
before and dump the contents of the string variable in the Name property
of the SaveAs dialog.
Dim sFileName As String
' locate your blocks of text
sFileName = "block of text"
'locate another block of text
sFileName = sFileName & " yet another block of text"
With Application.Dialogs(wdDialogFileSaveAs)
.Name = sFileName
.Show
End With
2)
If by any chance, y're not composing the filename during runtime
you can use Custom Document Properties to store values in yr case:
the filename that needs to be composed.
Whenever yr macro finds this block of text, transfer the contents to a
Custom Document Property. If another block of text is needed addtly
to compose the filename, concatenate the value of this Document Property
to this other block of text and proceed till the filename is complete.
Popup the SaveAs dialog, transferring the value of the document property
to the Name property of the SaveAs dialog.
Krgrds,
Perry
Quote:
> Perry,
> That's a lot closer than I've gotten by myself, but it doesn't look like
it
> will do the job because of the statement:
> .Name = "your file name"
> You see, the "your file name" part is supposed to be composed from the
> contents of the Clipboard.
> I think I must first build the "your file name" part by "concatenating"
the
> Clipboard contents with a bit more text (for example: " - Binder.doc") so
> that the final result is a valid filename (such as "1234 - Binder.doc").
> Once the macro composes the filename and stores into a variable, THEN I
want
> to save it using the routine you've offered.
> The Word Macro Recorder will do everything I need except this routine.
This
> step would be very simple for me to write in some of the ancient
programming
> languages I learned in the 70's and 80's -- and I'm sure it's pretty
simple
> in VBA, too. But other than knowing how to use the recorder, I don't
> "speak" VBA. So I'm lost.
> I greatly appreciate your help!
> Rick
> > Hi rsrsr,
> > Why not try something like:
> > With Application.Dialogs(wdDialogFileSaveAs)
> > .Name = "your file name"
> > .Show
> > End With
> > Krgrds,
> > Perry
> > > I'm trying to write a macro using the recorder that:
> > > (1) locates a small block of text in my document -- no problem
> > > (2) defines it -- no problem
> > > (3) places these contents into the Clipboard -- no problem
> > > (4) executes a File|Save As -- -- no problem
> > > (5) and then puts the clipboard contents in the Filename: box <------
> and
> > > there's the problem!
> > > I'm pretty sure I cannot do this without some VBA help to build a
string
> > > variable containing the new file name and then park that variable name
> > into
> > > the VBA command for "Write this to Disk."
> > > But I don't have a clue how to do this.
> > > Could somebody give me a push in the right direction?
> > > Thanks!
> > > Rick Rodgers