Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default word to excel format change

When copied my word table into excel sheet
2-0-0 becomes 2-0-0 which is correct but
2-4-0 becomes 02.04.2000 on excel cell. This is rather irritating.
I have to keep this "-" intact as i am doing parsing afterwards.
Any help or right direction ? Thank you very much in advance.

Part of my code to copy:
.........
wdDoc.Tables(1).Select
wdApp.Selection.Copy: Sh.Paste
wdApp.Quit
.............

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default word to excel format change

This worked for me

Sub test()
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Dim wdTble As Word.Table
Dim ws As Worksheet

Set ws = ActiveSheet
Dim rng As Excel.Range

Set ws = ActiveSheet
Set rng = ws.Range("A1")

Set wdApp = GetObject(, "word.application")
Set wdDoc = wdApp.ActiveDocument

Set wdTble = wdDoc.Tables(1)
With wdTble
Set rng = rng.Resize(.Rows.Count, .Columns.Count)
End With

' must be a way to avoid Select ?
wdTble.Select
wdApp.Selection.Copy

rng.NumberFormat = "@" ' as text

rng.PasteSpecial xlPasteValues

' maybe apply some other formats
With rng.Borders
.LineStyle = xlContinuous
.Weight = xlThin ' xlMedium
End With
rng.HorizontalAlignment = xlRight

End Sub

Regards,
Peter T

wrote in message
...
When copied my word table into excel sheet
2-0-0 becomes 2-0-0 which is correct but
2-4-0 becomes 02.04.2000 on excel cell. This is rather irritating.
I have to keep this "-" intact as i am doing parsing afterwards.
Any help or right direction ? Thank you very much in advance.

Part of my code to copy:
........
wdDoc.Tables(1).Select
wdApp.Selection.Copy: Sh.Paste
wdApp.Quit
............



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default word to excel format change

On May 3, 12:18*pm, "Peter T" <peter_t@discussions wrote:
This worked for me

Sub test()
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Dim wdTble As Word.Table
Dim ws As Worksheet

* * Set ws = ActiveSheet
* * Dim rng As Excel.Range

* * Set ws = ActiveSheet
* * Set rng = ws.Range("A1")

* * Set wdApp = GetObject(, "word.application")
* * Set wdDoc = wdApp.ActiveDocument

* * Set wdTble = wdDoc.Tables(1)
* * With wdTble
* * * * Set rng = rng.Resize(.Rows.Count, .Columns.Count)
* * End With

' must be a way to avoid Select ?
* * wdTble.Select
* * wdApp.Selection.Copy

* * rng.NumberFormat = "@" ' as text

* * rng.PasteSpecial xlPasteValues

* * ' maybe apply some other formats
* * With rng.Borders
* * * * .LineStyle = xlContinuous
* * * * .Weight = xlThin ' xlMedium
* * End With
* * rng.HorizontalAlignment = xlRight

End Sub

Regards,
Peter T

wrote in message

...



When copied my word table into excel sheet
2-0-0 becomes 2-0-0 which is correct but
2-4-0 becomes 02.04.2000 on excel cell. This is rather irritating.
I have to keep this "-" intact as i am doing parsing afterwards.
Any help or right direction ? Thank you very much in advance.


Part of my code to copy:
........
wdDoc.Tables(1).Select
wdApp.Selection.Copy: Sh.Paste
wdApp.Quit
............- Hide quoted text -


- Show quoted text -


Worked charmingly !

Thank you very much Peter.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change format for an individual word in a cell jaysan3 Excel Discussion (Misc queries) 1 August 28th 09 11:03 AM
Add Word and change format Kelvin Excel Discussion (Misc queries) 2 November 24th 05 11:02 PM
identify a word in a string then change the format of that word EazyExcel Excel Programming 2 May 15th 05 07:05 PM
Conditional format (word change) Onion Excel Worksheet Functions 2 February 8th 05 09:55 PM
Change format of single word in cell Zenon Excel Programming 1 June 22nd 04 04:02 PM


All times are GMT +1. The time now is 12:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"