ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   After pasting a Chart in Word, excel makes a "restart" (https://www.excelbanter.com/excel-programming/373300-after-pasting-chart-word-excel-makes-restart.html)

Carlo

After pasting a Chart in Word, excel makes a "restart"
 
Hi all

i have following code:
'----------------------------------------------------------
Dim WRDAPP As Word.Application
Dim WRDDOC As Word.Document

Set WRDAPP = CreateObject("Word.Application")
Set WRDDOC = WRDAPP.Documents.Open("C:\Test.doc")

WRDAPP.Visible = true
ActiveSheet.Shapes("chart1").Copy
WRDAPP.Selection.Paste
'----------------------------------------------------------

As soon as following line gets executed: "WRDAPP.Selection.Paste"
excel starts executing:
'----------------------------------------------------------
Private Sub Workbook_Open()
Form_Start.Show
End Sub
'----------------------------------------------------------

Why is this so? Does anyone has a clue?

Cheers Carlo

JNW

After pasting a Chart in Word, excel makes a "restart"
 
I don't know why that happens but you could insert a line to disable events
(application.enableevents = false) so that it won't go back the workbook_open
event. Just make sure to enable them again.
--
JNW


"Carlo" wrote:

Hi all

i have following code:
'----------------------------------------------------------
Dim WRDAPP As Word.Application
Dim WRDDOC As Word.Document

Set WRDAPP = CreateObject("Word.Application")
Set WRDDOC = WRDAPP.Documents.Open("C:\Test.doc")

WRDAPP.Visible = true
ActiveSheet.Shapes("chart1").Copy
WRDAPP.Selection.Paste
'----------------------------------------------------------

As soon as following line gets executed: "WRDAPP.Selection.Paste"
excel starts executing:
'----------------------------------------------------------
Private Sub Workbook_Open()
Form_Start.Show
End Sub
'----------------------------------------------------------

Why is this so? Does anyone has a clue?

Cheers Carlo


Carlo

After pasting a Chart in Word, excel makes a "restart"
 
Hi JNW

Thanks a lot, that did the job!

Still don't know why that happens.

Thanks again

Carlo

"JNW" wrote:

I don't know why that happens but you could insert a line to disable events
(application.enableevents = false) so that it won't go back the workbook_open
event. Just make sure to enable them again.
--
JNW


"Carlo" wrote:

Hi all

i have following code:
'----------------------------------------------------------
Dim WRDAPP As Word.Application
Dim WRDDOC As Word.Document

Set WRDAPP = CreateObject("Word.Application")
Set WRDDOC = WRDAPP.Documents.Open("C:\Test.doc")

WRDAPP.Visible = true
ActiveSheet.Shapes("chart1").Copy
WRDAPP.Selection.Paste
'----------------------------------------------------------

As soon as following line gets executed: "WRDAPP.Selection.Paste"
excel starts executing:
'----------------------------------------------------------
Private Sub Workbook_Open()
Form_Start.Show
End Sub
'----------------------------------------------------------

Why is this so? Does anyone has a clue?

Cheers Carlo



All times are GMT +1. The time now is 02:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com