Using Clipboard Contents to Develop Filename and Save to Desktop 
Author Message
 Using Clipboard Contents to Develop Filename and Save to Desktop

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



Thu, 07 Jul 2005 05:36:19 GMT  
 Using Clipboard Contents to Develop Filename and Save to Desktop
Hi rsrsr,

Why not try something like:

    With Application.Dialogs(wdDialogFileSaveAs)
    .Name = "your file name"
    .Show
    End With

Krgrds,
Perry



Quote:
> 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



Thu, 07 Jul 2005 06:34:37 GMT  
 Using Clipboard Contents to Develop Filename and Save to Desktop

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


Quote:
> 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



Thu, 07 Jul 2005 06:53:45 GMT  
 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



Thu, 07 Jul 2005 07:27:06 GMT  
 Using Clipboard Contents to Develop Filename and Save to Desktop
Hi rtrsr

The following article shows you how to get text on and off the clipboard

Manipulating the clipboard using VBA
http://www.mvps.org/word/FAQs/MacrosVBA/ManipulateClipboard.htm

--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
Word FAQs at http://www.multilinker.com/wordfaq
Please post any follow-up in the newsgroup. I do not reply to Word questions
by email


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



Thu, 07 Jul 2005 07:26:01 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Paste clipboard contents into filename during save- ?

2. How TO : Automatic copy (ctrl-c) + clipboard + paste (ctrl-v) + save as filename

3. How TO : Automatic copy (ctrl-c) + clipboard + paste (ctrl-v) + save as filename

4. How TO : Automatic copy (ctrl-c) + clipboard + paste (ctrl-v) + save as filename

5. How TO : Automatic copy (ctrl-c) + clipboard + paste (ctrl-v) + save as filename

6. How COM components developed for WebClasses are diff from others say used on Desktop

7. Copying DBGrid contents to clipboard (Or copying a table from a Data component to clipboard)

8. Help for getting rid of the contents in clipboard(office) using VBA

9. Using clipboard contents in macro?

10. Using clipboard contents in FIND prompt.

11. Access XP: Clearing the clipboard / not saving data to the clipboard

12. Using Title Doc Property As FileName When Saving Document

 

 
Powered by phpBB® Forum Software