P
pedro
Hi I have problems when I try to copy paste different columns (ranges)
to a word doc.
This is the code I'm using:
Dim wordapp As Word.Application
Dim WordDoc As Word.Document
Set wordapp = New Word.Application
Set WordDoc = wordapp.Documents.Add
WordDoc.PageSetup.Orientation = wdOrientLandscape
Dim x As Integer
x = max + 1
Sheets("registrations").Range("B1:F" & x & ",I1:I" & x & ",K1:L" &
x & ",N1:N" & x).Copy
WordDoc.Range.PasteSpecial
The problem that I have, is that it doesn't copy the different
columns, it copies all the columns between B and N, so G, H, J, M are
alsow included.
Now I noticed that the same thing occurs when I try to simulate this
with manual actions. If I select 2 columns for example A and C, copy
and past them in a Word doc, column B is also been copied.
What I alsow tried was to delete the unneeded columns afterwards: with
this code:
WordDoc.Tables(1).Columns(12).Delete
WordDoc.Tables(1).Columns(10).Delete
WordDoc.Tables(1).Columns(8).Delete
WordDoc.Tables(1).Columns(7).Delete
But then I receive the following error:
"Cannot access individual columns in this collection because the table
has mixed cell widths."
I alsow tried copy pasting the ranges one after another, ben the I
receive the following error:
"Microsoft excel is waiting for an OLE object to ..."
Somebody knows a solutions for this situation.
Thanks in advance, Nik
to a word doc.
This is the code I'm using:
Dim wordapp As Word.Application
Dim WordDoc As Word.Document
Set wordapp = New Word.Application
Set WordDoc = wordapp.Documents.Add
WordDoc.PageSetup.Orientation = wdOrientLandscape
Dim x As Integer
x = max + 1
Sheets("registrations").Range("B1:F" & x & ",I1:I" & x & ",K1:L" &
x & ",N1:N" & x).Copy
WordDoc.Range.PasteSpecial
The problem that I have, is that it doesn't copy the different
columns, it copies all the columns between B and N, so G, H, J, M are
alsow included.
Now I noticed that the same thing occurs when I try to simulate this
with manual actions. If I select 2 columns for example A and C, copy
and past them in a Word doc, column B is also been copied.
What I alsow tried was to delete the unneeded columns afterwards: with
this code:
WordDoc.Tables(1).Columns(12).Delete
WordDoc.Tables(1).Columns(10).Delete
WordDoc.Tables(1).Columns(8).Delete
WordDoc.Tables(1).Columns(7).Delete
But then I receive the following error:
"Cannot access individual columns in this collection because the table
has mixed cell widths."
I alsow tried copy pasting the ranges one after another, ben the I
receive the following error:
"Microsoft excel is waiting for an OLE object to ..."
Somebody knows a solutions for this situation.
Thanks in advance, Nik