Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Manipulating MS Word from Excel??


Hi all i have some code below that opens Word adds a document and pastes
the contents of a range in to it, my problem is that i would like the
contents to be pasted on the right hand side if the document, thats
what the vbTab's are for below but it doesnt work it just hangs after
running that line........i'm no whizz at this so if anyone could give
me the correction i would be very grateful!

Regards,
Simon

Sub wrdstart()
Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Word.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Word.Application")
End If
appwd.Visible = True
On Error GoTo 0
With appwd
..documents.Add
Selection.TypeText Text:=vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
& _
vbTab & vbTab & vbTab
Range("A1:A5").Copy

..Selection.Paste

End With
End Sub


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=555537

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Manipulating MS Word from Excel??


Thanks for your reply Papou, i had already tried that it still pastes
the information to the top left of the word document but i need it to
appear in the top right..............any other ideas?

regards,
Simon


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=555537

  #4   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 65
Default Manipulating MS Word from Excel??

SImon:

Once you're in Word, you have access to all of Word's properties and
methods. Why not set a Range to where you want to paste this, and then
use
Range.ParagraphFormat.Alignment wdAlignParagraphRight
to set it against the right edge? Much less messy than all those tabs.

Ed

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Manipulating MS Word from Excel??


Thanks Ed, worked for me!
Regards,
Simon


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=555537



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Manipulating MS Word from Excel??

Hi
This seems to do most of what you want

Sub wrdstart()
Dim appwd As Word.Application
Dim NewDoc As Word.Document
On Error GoTo notloaded
Set appwd = GetObject(, "Word.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Word.Application")
End If
appwd.Visible = True
On Error GoTo 0
Set NewDoc = appwd.Documents.Add
With NewDoc
.ActiveWindow.Selection.TypeText Text:=vbTab & vbTab & vbTab & vbTab
& vbTab & vbTab & _
vbTab & vbTab & vbTab
Range("A1:A5").Copy
..ActiveWindow.Selection.PasteExcelTable False, False, False
End With
End Sub

I'm no wizz either! The paste seems to go over the tabs, so you
probably need to set some property of the Selection object to stop that
and make the paste go to the end?

regards
Paul

Simon Lloyd wrote:
Hi all i have some code below that opens Word adds a document and pastes
the contents of a range in to it, my problem is that i would like the
contents to be pasted on the right hand side if the document, thats
what the vbTab's are for below but it doesnt work it just hangs after
running that line........i'm no whizz at this so if anyone could give
me the correction i would be very grateful!

Regards,
Simon

Sub wrdstart()
Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Word.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Word.Application")
End If
appwd.Visible = True
On Error GoTo 0
With appwd
.documents.Add
Selection.TypeText Text:=vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
& _
vbTab & vbTab & vbTab
Range("A1:A5").Copy

.Selection.Paste

End With
End Sub


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=555537


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
Help with manipulating data in excel? jock Excel Discussion (Misc queries) 3 July 29th 08 03:24 PM
Manipulating embeded exccel in word (Repost) JD Excel Programming 6 February 24th 05 03:09 PM
Manipulating embeded exccel in word JD Excel Programming 0 February 9th 05 02:26 PM
Manipulating Excel pie charts with VB Debra Dalgleish[_2_] Excel Programming 0 July 24th 03 01:08 AM
Manipulating Excel pie charts with VB Andrew[_16_] Excel Programming 0 July 24th 03 12:59 AM


All times are GMT +1. The time now is 05:57 AM.

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

About Us

"It's about Microsoft Excel"