H
Hari
Hi,
Its been sometime since I posted my queries in this forum. New IT
policy in the compnay, proxy net connection .. i dunno what, but Im not
able to access NG's through Outlook and posting through Google is....
I have some data in word which has to be transfered to Excel
automatically.
Using Jon P's Excel to PPT automation examples I wrote the following
code in Word.
a) Problem is if I have some tables in Word then the table borders dont
get transfered to excel. Is this normal? On the other hand if I
manually copy paste from Word to Excel then do paste special and choose
HTML, one can get borders etc same as Word. if I use the syntax --
oExcelWorkS.Range("a1").PasteSpecial Format:=wdPasteHTML,
Link:=False, DisplayAsIcon:= _
False
then I get Compile error: named argument not found in Format above.
Why am I getting this error? What would be the correct synax?
b) I think my Present code is equivalent to a paste special - text or
unicode text (which one is it?) Whats the different between the 2?
c) In word Iam using early binding to excel and when I write the code
line
-- oExcelWorkS.Range("a1").PasteSpecial -- and immediately after
Pastespecial if I give a space then word prompts with some excel
constants - xlpasteall, xlpasteformats --etc, but when I use any of
these then I get a runtime error at this line (1004) -- paste special
method of range class failed? Why is this happening
Regards,
Hari
India
Option Explicit
Sub TransferDatatoExcel()
'Set the reference to Microsoft Excel 11.0 Object library (or
10.0/9.0 _
depending on your version of Office) in Tools - References
Dim oExcel As Excel.Application
Dim oExcelWorkB As Excel.Workbook
Dim oExcelWorkS As Excel.Worksheet
Dim fileName As Double
Application.ScreenUpdating = False
Selection.WholeStory
Selection.Copy
Set oExcel = CreateObject("excel.application")
oExcel.Visible = msoTrue
Set oExcelWorkB = oExcel.Workbooks.Add
Set oExcelWorkS = oExcelWorkB.Worksheets("sheet1")
oExcelWorkS.Range("a1").PasteSpecial xlPasteValues
fileName = Now()
With oExcelWorkB
.SaveAs "d:\Time Stamp - " & fileName & ".xls"
.Close
End With
oExcel.Quit
Set oExcel = Nothing
Set oExcelWorkB = Nothing
Set oExcelWorkS = Nothing
Application.ScreenUpdating = True
End Sub
Its been sometime since I posted my queries in this forum. New IT
policy in the compnay, proxy net connection .. i dunno what, but Im not
able to access NG's through Outlook and posting through Google is....
I have some data in word which has to be transfered to Excel
automatically.
Using Jon P's Excel to PPT automation examples I wrote the following
code in Word.
a) Problem is if I have some tables in Word then the table borders dont
get transfered to excel. Is this normal? On the other hand if I
manually copy paste from Word to Excel then do paste special and choose
HTML, one can get borders etc same as Word. if I use the syntax --
oExcelWorkS.Range("a1").PasteSpecial Format:=wdPasteHTML,
Link:=False, DisplayAsIcon:= _
False
then I get Compile error: named argument not found in Format above.
Why am I getting this error? What would be the correct synax?
b) I think my Present code is equivalent to a paste special - text or
unicode text (which one is it?) Whats the different between the 2?
c) In word Iam using early binding to excel and when I write the code
line
-- oExcelWorkS.Range("a1").PasteSpecial -- and immediately after
Pastespecial if I give a space then word prompts with some excel
constants - xlpasteall, xlpasteformats --etc, but when I use any of
these then I get a runtime error at this line (1004) -- paste special
method of range class failed? Why is this happening
Regards,
Hari
India
Option Explicit
Sub TransferDatatoExcel()
'Set the reference to Microsoft Excel 11.0 Object library (or
10.0/9.0 _
depending on your version of Office) in Tools - References
Dim oExcel As Excel.Application
Dim oExcelWorkB As Excel.Workbook
Dim oExcelWorkS As Excel.Worksheet
Dim fileName As Double
Application.ScreenUpdating = False
Selection.WholeStory
Selection.Copy
Set oExcel = CreateObject("excel.application")
oExcel.Visible = msoTrue
Set oExcelWorkB = oExcel.Workbooks.Add
Set oExcelWorkS = oExcelWorkB.Worksheets("sheet1")
oExcelWorkS.Range("a1").PasteSpecial xlPasteValues
fileName = Now()
With oExcelWorkB
.SaveAs "d:\Time Stamp - " & fileName & ".xls"
.Close
End With
oExcel.Quit
Set oExcel = Nothing
Set oExcelWorkB = Nothing
Set oExcelWorkS = Nothing
Application.ScreenUpdating = True
End Sub