automation word/excel copy/paste

G

Guest

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
 
L

Larry Linson

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
 
G

Guest

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/com...misc&mid=9208d844-faef-404b-a82d-bdbc4477b2c2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top