PC Review


Reply
Thread Tools Rate Thread

automation word/excel copy/paste

 
 
=?Utf-8?B?U0Ft?=
Guest
Posts: n/a
 
      25th Jan 2006
Hi

I have some code and i don't know why sometimes i get errors, sometimes i
can get parts of it to work. the objective: run a report, save it as a word
document, then copy it on to the clipboard, and delete the file. then i want
to start a new excel spreadsheet, paste my clipboard in it, and save it. then
i will add more code which is not written yet.

this is the code:

Code:
Set MyWordInstance = New Word.Application
MyWordInstance.Documents.Open "C:\tempRpt.rtf"
With MyWordInstance
.Selection.WholeStory
.Selection.Find.ClearFormatting
.Selection.Find.Replacement.ClearFormatting
With .Selection.Find
.Text = "^m"
.Replacement.Text = ""
.Forward = True
End With
.Selection.Find.Execute Replace:=wdReplaceAll
.Selection.WholeStory
.Selection.Copy
End With
MyWordInstance.ActiveDocument.Close
MyWordInstance.Quit
'Kill "C:\tempPayperiodRpt.rtf"

Set MyExcelInstance = New Excel.Application
MyExcelInstance.Workbooks.Add
MyExcelInstance.ActiveWorkbook.SaveAs "C:\PPP"
MyExcelInstance.ActiveWorkbook.ActiveSheet.Range("B5").Select
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range("B5")
MyExcelInstance.ActiveWorkbook.Save
MyExcelInstance.ActiveWorkbook.Close
MyExcelInstance.Quit
 
Reply With Quote
 
 
 
 
Larry Linson
Guest
Posts: n/a
 
      27th Jan 2006
And did you have a question? Newsgroups are good for getting answers to
specific questions, but aren't good for posting code and expecting someone
to test and solve problems without having the whole database application.

See http://www.mvps.org/access/netiquette.htm for other good suggestions on
effective use of newsgroups.

Larry Linson
Microsoft Access MVP

"SAm" <(E-Mail Removed)> wrote in message
news:6F73B21D-3773-4A3D-952B-(E-Mail Removed)...
> Hi
>
> I have some code and i don't know why sometimes i get errors, sometimes i
> can get parts of it to work. the objective: run a report, save it as a
> word
> document, then copy it on to the clipboard, and delete the file. then i
> want
> to start a new excel spreadsheet, paste my clipboard in it, and save it.
> then
> i will add more code which is not written yet.
>
> this is the code:
>
> Code:
> Set MyWordInstance = New Word.Application
> MyWordInstance.Documents.Open "C:\tempRpt.rtf"
> With MyWordInstance
> .Selection.WholeStory
> .Selection.Find.ClearFormatting
> .Selection.Find.Replacement.ClearFormatting
> With .Selection.Find
> .Text = "^m"
> .Replacement.Text = ""
> .Forward = True
> End With
> .Selection.Find.Execute Replace:=wdReplaceAll
> .Selection.WholeStory
> .Selection.Copy
> End With
> MyWordInstance.ActiveDocument.Close
> MyWordInstance.Quit
> 'Kill "C:\tempPayperiodRpt.rtf"
>
> Set MyExcelInstance = New Excel.Application
> MyExcelInstance.Workbooks.Add
> MyExcelInstance.ActiveWorkbook.SaveAs "C:\PPP"
> MyExcelInstance.ActiveWorkbook.ActiveSheet.Range("B5").Select
> ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range("B5")
> MyExcelInstance.ActiveWorkbook.Save
> MyExcelInstance.ActiveWorkbook.Close
> MyExcelInstance.Quit



 
Reply With Quote
 
=?Utf-8?B?U0Ft?=
Guest
Posts: n/a
 
      27th Jan 2006
fyi, i posted the same posting on the excel newsgroups site and someone there
was able to help me.
maybe i shouldn;t have posted it on the access site because my question was
regarding the excel portion (and i appologize for not being specific about
it).

thanks atleast for responding. i was starting to think that these newsgroups
are not being read.

i will copy paste a link to the response on the excel newsgroups.

thanks,

sam
link to the same post on the excel newsgroups:
http://www.microsoft.com/office/comm...d-bdbc4477b2c2


"Larry Linson" wrote:

> And did you have a question? Newsgroups are good for getting answers to
> specific questions, but aren't good for posting code and expecting someone
> to test and solve problems without having the whole database application.
>
> See http://www.mvps.org/access/netiquette.htm for other good suggestions on
> effective use of newsgroups.
>
> Larry Linson
> Microsoft Access MVP
>
> "SAm" <(E-Mail Removed)> wrote in message
> news:6F73B21D-3773-4A3D-952B-(E-Mail Removed)...
> > Hi
> >
> > I have some code and i don't know why sometimes i get errors, sometimes i
> > can get parts of it to work. the objective: run a report, save it as a
> > word
> > document, then copy it on to the clipboard, and delete the file. then i
> > want
> > to start a new excel spreadsheet, paste my clipboard in it, and save it.
> > then
> > i will add more code which is not written yet.
> >
> > this is the code:
> >
> > Code:
> > Set MyWordInstance = New Word.Application
> > MyWordInstance.Documents.Open "C:\tempRpt.rtf"
> > With MyWordInstance
> > .Selection.WholeStory
> > .Selection.Find.ClearFormatting
> > .Selection.Find.Replacement.ClearFormatting
> > With .Selection.Find
> > .Text = "^m"
> > .Replacement.Text = ""
> > .Forward = True
> > End With
> > .Selection.Find.Execute Replace:=wdReplaceAll
> > .Selection.WholeStory
> > .Selection.Copy
> > End With
> > MyWordInstance.ActiveDocument.Close
> > MyWordInstance.Quit
> > 'Kill "C:\tempPayperiodRpt.rtf"
> >
> > Set MyExcelInstance = New Excel.Application
> > MyExcelInstance.Workbooks.Add
> > MyExcelInstance.ActiveWorkbook.SaveAs "C:\PPP"
> > MyExcelInstance.ActiveWorkbook.ActiveSheet.Range("B5").Select
> > ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range("B5")
> > MyExcelInstance.ActiveWorkbook.Save
> > MyExcelInstance.ActiveWorkbook.Close
> > MyExcelInstance.Quit

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy & paste from Excel to Word HeliBarry Microsoft Excel Misc 1 29th Feb 2008 01:00 PM
Excel Automation : numbers Copy/Paste issue from VB6 olivier.sanzot@gmail.com Microsoft Excel Programming 6 7th Jul 2006 09:18 AM
Won't let me copy and paste from Excel to Word =?Utf-8?B?U3VlQjU3?= Microsoft Excel Misc 0 14th Nov 2005 05:14 PM
copy multiple worksheets of a workbook, and paste onto a Word document ( either create new doc file or paste onto an existing file.) I need this done by VBA, Excel Macro Steven Microsoft Excel Programming 1 17th Oct 2005 08:56 AM
copy excel paste to word =?Utf-8?B?Q2lhcmE=?= Microsoft Excel Misc 0 20th May 2005 09:39 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:47 PM.