Selection.PasteAndFormat method

In Word 2007, when I record a macro that does a regular Paste from the
clipboard, it records it as

Selection.PasteAndFormat(wdPasteDefault)

It also seems to use the same 'wdPasteDefault' type even if I choose
either--

Paste Special | Unformatted Text; or
Paste Special | Unformatted Unicode Text

I'm not sure why it would use the same type for all of these.  But the
strange thing is that if I go to the Word Developer Help for the
PasteAndFormat method, and I see what values there are for the
wdRecoveryType, it lists wdPasteDefault as "Not Supported".  Thanks
for any thoughts about this.
0
Rick
2/11/2010 8:07:26 PM
word.vba.general 1023 articles. 0 followers. Follow

2 Replies
9594 Views

Similar Articles

[PageSpeed] 36

The macro recorder has never been a perfect tool. However in this instance - 
Edit > PasteSpecial unformatted text records as

Selection.PasteSpecial Link:=False, DataType:=wdPasteText, Placement:= _
        wdInLine, DisplayAsIcon:=False

Unformatted UnicodeText records as

Selection.PasteSpecial Link:=False, DataType:=20, Placement:=wdInLine, _
        DisplayAsIcon:=False

Data type 20 is wdFormatSurroundingFormattingWithEmphasis

and a simple paste records as

Selection.Paste

in Word 2007 all of which are correct.

Selection.PasteAndFormat (wdPasteDefault)

Uses the default format for the material on the clipboard (that which would 
be highlighted if you select the edit > paste special dialog). This varies 
with the type of material in question, so does not represent a fixed 
definition.

To force a particular type create the macro manually e.g.

Sub PasteUnfText()
    On Error GoTo oops
    Selection.PasteSpecial _
    DataType:=wdPasteText, _
    Placement:=wdInLine
    End
oops:
Beep
End Sub

or with Word 2007, you can set the default paste options to your preferences 
in Word Options

-- 
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


"Rick" <rick0726@verizon.net> wrote in message 
news:05bbd7d5-2efb-49ba-8bb8-23c5bbeefee6@c28g2000vbc.googlegroups.com...
> In Word 2007, when I record a macro that does a regular Paste from the
> clipboard, it records it as
>
> Selection.PasteAndFormat(wdPasteDefault)
>
> It also seems to use the same 'wdPasteDefault' type even if I choose
> either--
>
> Paste Special | Unformatted Text; or
> Paste Special | Unformatted Unicode Text
>
> I'm not sure why it would use the same type for all of these.  But the
> strange thing is that if I go to the Word Developer Help for the
> PasteAndFormat method, and I see what values there are for the
> wdRecoveryType, it lists wdPasteDefault as "Not Supported".  Thanks
> for any thoughts about this. 


0
Graham
2/12/2010 7:35:29 AM
Thanks.  In Word 2007, on the clipboard I have a string of text I just
copied from my Word document.  When I then record a macro and do any
of these --

- regular Paste
- Paste Special | Unformatted text
- Paste Special | Unformatted Unicode text

the code that I get in the VBA Editor is just --

Selection.PasteAndFormat (wdPasteDefault)

I wonder why I'm getting a different result than you?

On Feb 12, 2:35=A0am, "Graham Mayor" <gma...@REMOVETHISmvps.org> wrote:
> The macro recorder has never been a perfect tool. However in this instanc=
e -
> Edit > PasteSpecial unformatted text records as
>
> Selection.PasteSpecial Link:=3DFalse, DataType:=3DwdPasteText, Placement:=
=3D _
> =A0 =A0 =A0 =A0 wdInLine, DisplayAsIcon:=3DFalse
>
> Unformatted UnicodeText records as
>
> Selection.PasteSpecial Link:=3DFalse, DataType:=3D20, Placement:=3DwdInLi=
ne, _
> =A0 =A0 =A0 =A0 DisplayAsIcon:=3DFalse
>
> Data type 20 is wdFormatSurroundingFormattingWithEmphasis
>
> and a simple paste records as
>
> Selection.Paste
>
> in Word 2007 all of which are correct.
>
> Selection.PasteAndFormat (wdPasteDefault)
>
> Uses the default format for the material on the clipboard (that which wou=
ld
> be highlighted if you select the edit > paste special dialog). This varie=
s
> with the type of material in question, so does not represent a fixed
> definition.
>
> To force a particular type create the macro manually e.g.
>
> Sub PasteUnfText()
> =A0 =A0 On Error GoTo oops
> =A0 =A0 Selection.PasteSpecial _
> =A0 =A0 DataType:=3DwdPasteText, _
> =A0 =A0 Placement:=3DwdInLine
> =A0 =A0 End
> oops:
> Beep
> End Sub
>
> or with Word 2007, you can set the default paste options to your preferen=
ces
> in Word Options
>
> --
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> Graham Mayor - =A0Word MVP
>
> My web sitewww.gmayor.com
> Word MVP web sitehttp://word.mvps.org
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>
> "Rick" <rick0...@verizon.net> wrote in message
>
> news:05bbd7d5-2efb-49ba-8bb8-23c5bbeefee6@c28g2000vbc.googlegroups.com...
>
>
>
> > In Word 2007, when I record a macro that does a regular Paste from the
> > clipboard, it records it as
>
> > Selection.PasteAndFormat(wdPasteDefault)
>
> > It also seems to use the same 'wdPasteDefault' type even if I choose
> > either--
>
> > Paste Special | Unformatted Text; or
> > Paste Special | Unformatted Unicode Text
>
> > I'm not sure why it would use the same type for all of these. =A0But th=
e
> > strange thing is that if I go to the Word Developer Help for the
> > PasteAndFormat method, and I see what values there are for the
> > wdRecoveryType, it lists wdPasteDefault as "Not Supported". =A0Thanks
> > for any thoughts about this.- Hide quoted text -
>
> - Show quoted text -

0
Rick
2/12/2010 7:32:28 PM
Reply:

Similar Artilces:

Combo box list selection based on earlier selection by user
HI, I have a form that has a combo box 1 (Product) that reads a the Product table and has a unique id attached to each product (RO#). There is a second combo box 2 that is RO#. Now what I would like to do is when a user selects a Product in combo box 1, the system should lookup the Product selected from combo box 1 and upload the corresponding RO# in the combo box 2 list. Now I am using both combo boxes as Unbound and in the combo box 2 I have the two columns Product and RO# - in the Criteria row of RO# I have the following: Like IIf([Forms]![xa_f_lookup]![RO#]=" ",[Forms]![x...

Run report on multi selected records.
I try to make a report for a custom entity that works like the Account Summary: let's say that it's Customer's Inquiry Summary for entity Customer's Inquiry I made the report so that I'm able to run the report on Customer's Inquiry Form. But when I select multi records in the list of Customer's Inquiry and run report, only one record is show in one page of the the report. I would like to have the selected records appear in the report with each record on each page. How can I do this? ...

Can't select objects in Excel 2007
I'm trying to create a form in Excel 2007, and although I can manipulate, copy & paste controls (check boxes, etc) I can't select multiple objects to align them, etc. I've checked on-line help (and have followed the instructions), and other websites, but no one seems to have indicated a problem. It is extremely cumbersome and I need a solution. Any ideas? Thanks in advance, Jim Berglund I know this is about a year too late, but it may help others who have stumbled across this page looking for similar help. On the Home tab, in the Editing group, click Find & Select....

2.0 : fastest read-only forward-only loading method
In 2.0 what is the fastest way to iterate through an element set in a read-only forward-only XMLDocument ? For example , load the key/value pairs in the following xml doc into a hashtable : <Mappings> <Mapping MappingKey="AL" MappingValue="Alabama" /> <Mapping MappingKey="CA" MappingValue="Alabama" /> </Mappings> John A Grandy wrote: > In 2.0 what is the fastest way to iterate through an element set in a > read-only forward-only XMLDocument ? Create an XmlReader and read out the nodes you are looking for...

Lot Selection not Showing when I select PO on Receiving Entry
Usually, the Lot selection screen would pop up when I select a PO at the Line Detail of the Receivings Entry, now it does not! And GP will let items post without a lot number! It seems as if a setting has changed. Any ideas anyone? Any help is appreciated. Thanks, R Are you sure the item is marked to track lots? This wiould be set item by item on the Item Maintenance Options window. -- Richard L. Whaley Author / Consultant / MVP 2006-2008 Documentation for Software Users Get our Free Tips and Tricks Newsletter and check out our books at http://www.AccoladePublications.com &q...

How do I disable the workbook close method
If I have multiple workbooks open, how can I programmatically prevent the users from using the close button (or file option) to close the workbook? I need that all to be done through my code. Is this possible? ~Jenny Private Sub Workbook_BeforeClose(Cancel As Boolean) If Not MyClose Then Cancel = True Endif End Sub The myClose variable should be a global Boolean, which you set to True in your code. This code goes in the Thisworkbook code module. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if...

Select contact then hangs
Hi, please help. I have a user that when she selects a contact using To: in a new email, after selecting 2, it closes outlook??. Spec is W2kSP4\office2k with all windows updates and office updates installed. Profile has been deleted and re-created, plus i have set up personal folders and moved contacts into there, and set that folder as a default, but makes no difference. Please help. ...

Selecting rows from various sheets
Hi all, I have several sheets with a few columns in each. One colum in each sheet has a unique value. Most of these unique values are th same in each sheet but not all. Is there any way that I can set up new sheet that will have the unique value in column 1 and th corresponding column values frommeach sheet beside it. For example Sheet 1 aa 1 1 1 bb 2 2 2 cc 3 3 3 Sheet 2 aa 4 4 cc 5 5 Result aa 1 1 1 4 4 bb 2 2 2 cc 3 3 3 5 5 Thanks alot, Sha -- sha ----------------------------------------------------------------------- shav's Profile: http...

select text in Calendar
I'm working on a calendar in Publisher. I'm adding text into a cell by spacing down 1 point, then typing in 8 points. Doing fine until April. At that time, I can only select cells (whole days). It will not let me select the text. Help is no help. Any hints out there. Did I accidentally select something to do this? Bonnie Have you added a picture to the cell or a shape? If you have send it to the back, make the cell no fill and try again. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "GoBonnieGo" <GoB...

macro to filter data based on selected data
Hi, I am looking for a macro that requests input of a reference code and then a date and then filters the data in my spreadsheet based on this criteria. I am using excel 2007. Any help with this will be greatly appreciated. You can probably record a macro while doing it manually and then clean it up and add input boxes to ask the question or input your variable in a cell and use that. If all else fails, If desired, send your file to my address below. I will only look if: 1. You send a copy of this message on an inserted sheet 2. You give me the newsgroup and the ...

Link select with a blast
I have Win 7 Home Premium, x64. Quite often, when I select a link, a mouse pointer changes to a palm with a blast. I understand, the palm is the standard mouse pointer for link select, but what is the blast? What it indicates? -- Ilya Zeldes Fort Myers, Florida Hi Ilya, I suspect that this is being caused by a tracking program. Run something like Ad-Aware and see if it indicates a tracking company. If so, you can delete it, however, it might prevent you from accessing that particular website. Dave "Ilya Zeldes" wrote in message news:7A6FF9B1-5512-44...

Select Case in a Change Event
Hi, I am trying to use a worksheet Change Event to trap changes to specific columns. depending on which column is chnaged by the user, the value in another ciolumn will be altered; so, changes in either column O or P will update column Q, changes in either column T or U will update column V and changes in column Z or AA will update column AB. What I can't figure out is the Select Case bit (where I've got the shouted question below). Here's what I've put together, any comments would be much appreciated. Private Sub Worksheet_Change(ByVal Target As Range) ...

Select Records based another table...
This may be very elementary, but i can't wrap my brain around it. I have tried to dummy it down as much as i can for myself, with plans of adapting it into something working. I have three tables that look like the following: Tbl 1: ProdID A B C 1 $1 $2 $3 2 $4 $5 $6 3 $7 $8 $9 Tbl 2: RmNum ProdID 1 3 1 2 2 1 2 2 Tbl 3: RmNum Style 1 A 2 C Relationships are: [tbl1 ProdID] ------ [tbl2 ProdID] [tbl2 RmNum] ...

Multi-Select List Box Does Not Retain Selected Items
I created an Outlook Form in 2003. But when I select items in the list box they do not remain select when I select another control on the form. Any suggestions? Did you bind the list box to a keywords field? -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "kaykay" <anonymous@discussions.microsoft.com> wrote in message news:276dd01c4638d$bd5af590$a501280a@phx.gbl... > I created an Outlook Form in 2003. But when I select > items i...

VBA
I am very new to VBA and access and have a question regarding a SELECT statement. I am going to run a select (recordset - so I can loop through and process each record) but on my SELECT I want to make sure I return at least 20 rows, otherwise I am going to change my WHERE clause to include more rows. Is there an easy way to do this or do I need to just do an inital SELECT COUNT(*) and then decide which WHERE clause to use?? Do you have an example I can look at? Thank you in advance! AJ On Fri, 14 Dec 2007 17:14:00 -0800, AJ <AJ@discussions.microsoft.com> wrote: I would not first ...

Drop down list quicker selection
We are using Excel 2003 We created a drop down list using the Data\Validation process, which works fine. When the arrow within a cell is clicked on to show the drop down list, how can you quickly select one of the many names in the list just by typing the first character of a name within the list. At the moment, we have to scroll up and down the list to select a particular name, which in itself isn't a problem, but slows down the process of finding the right name. Can the names within the list be alphabetically grouped when inputting the first character from the keyboard, and spee...

Change Form/Report Query Based on User Selection
I have a form and report based on a query. I need to change the query based on what the user selects on a form. Using VBA in MS Access 2002, can I change a single field in an existing query from GROUP BY to LAST? This process would be initiated by a click event on a form. Thanks in advance for any help. I would say only if you are willing to construct the entire query string in VBA and then apply that string as the source of the report. John Spencer Access MVP 2002-2005, 2007-2009 The Hilltop Institute University of Maryland Baltimore County Wayne wrote: > I have a form ...

Selected fields to update
I need to have the ability, in OL'07, when I try to copy in a contact and am told there is a duplicate, to be able to select which fields I want updated and which not. Is that possible built-in or add-in? -- Boris You may find this of interest - ContactGenie DataPorter 2.0 - specifically handles updating of pre-existing contacts allowing you to define which fields you want to import/update from your input data file (custom forms/fields supported). Features: http://www.contactgenie.com/cg20features.htm Download" http://www.contactgenie.com/cg20dlorder.htm Karl _...

How do I find the currently selected Scenario?
Hi, Maybe this is a simple thing, but I don't seem to be able to track it down. I have an Excel sheet with a couple of Scenarios defined. I am trying to implement some VBA functions where I need to know which Scenario is currently selected. Does anyone know how I determine the active Scenario from VBA? Any help will be greatly appreciated. Thanks in advance. Best regards. hi, (?) > Maybe this is a simple thing, but I don't seem to be able to track it down. > I have an Excel sheet with a couple of Scenarios defined. > I am trying to implement some VBA functi...

Criteria for select query.
I have Access2003. I need a criteria expression to select certain data from a query QryLedgerTxns. When the ledger is reconciled with the bank statement, that statement date is manually entered into a QryLedgerTxns field called "DateStatement". The "DateStatement" field matches a ledger transaction field called "Withdrawal" My aim is to add up all the sums in the "Withdrawal" field *not* reconciled with the bank statement. The "Withdrawal" field is currency. The "DateStatement" field is Date/time. Therefo...

set a variable to value in a select statement
I know how to do this: SET @total = (SELECT SUM(Salary) FROM Employee) But is it possible to do soemthing like this without 2 separate SET statements?: SET @total, @tipstotal = (SELECT SUM(Salary), SUM(Tips) FROM Employee) If so, how? SELECT @total = SUM(Salary), @tipstotal = SUM(Tips) FROM Employee Tom "Keith G Hicks" <krh@comcast.net> wrote in message news:utAHRun$KHA.5536@TK2MSFTNGP02.phx.gbl... >I know how to do this: > > SET @total = (SELECT SUM(Salary) FROM Employee) > > But is it possible to do soemthing like this with...

Select All and Copy not available in GAL
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Email Client: Exchange I have well over 200 contacts in our GAL.. <br> Server is Exchange 2003 <br> Client is 2008 (mac) <br><br>I can view all contacts from our GAL but the application (Entourage) doesn't allow me to &quot;Add to Address Book&quot; more than one contact at a time one for 200 contacts for 200 Macs. But I think I shouldn't be doing the Computer's job!? <br><br>Anyone have an AppleScript to circumvent this 'feature'? Or maybe some...

Select Previously Selected worksheet (and/or select previously selected workbook)
Is anyone aware of VBA code that would allow me to auto-select the previously active worksheet (within a particular workbook....or within another open workbook)? In essence, I am trying to build a routine that will allow me to automatically do a vlookup between two data lists in two sheets with a single step, rather than go through the process of specifying the particular columns Thanks for any suggestions. ...

Nested select/update
Hi I have two tables, ProjectLog and OrderHeader. There are address fields in both and I need to update the address fields in ProjectLog where they are blank with the data held in OrderHeader. There is one record per Project in ProjectLog and potentially multiple OrderHeader records referring to each project. I just want to take the first entry from OrderHeader for a Project and update the address information in ProjectLog if it is blank. I know I need to do some form of nested select/update statement but my efforts so far have been pretty lame and so I am hoping someone here can help me....

Select checkboxes to select which pages to print
Hi, Background 1: I have a mail-merge coming from a non-Office program that can come only from this non-Office program (in other words I do not have a way to get the mail-merge data I need otherwise). In other words I can only use this non-Office program to PUSH the mail-merge data into Word; I cannot use Word to PULL the data from this non-Office program. Further this non-Office program, once it merges the data into a document template, loads Word for me so I can see the new document created from the template and the merge. All I'm basically saying here is I'm li...