Hallo,
ik gebruik volgende code om vanuit word excel tabellen in het word document te plaatsen (deed het perfect in 2003)
de eerste, Macro10 doet het nog
de tweede Macro10_4 doet het niet
er wordt een compileerfout aangegeven bij path: de tekst erbij is kan niet toewijzen aan een alleen-lezen eigenschap.
Voor mij lijken de twee codes identiek?
alvast bedankt
Nico
Sub Macro10()
'
Dim Path
'Zoeken van tabel001
Selection.Find.ClearFormatting
With Selection.Find
.Text = "{{tabel006}}"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
'Excel starten en wokrbook openen
Set xlApp = CreateObject("Excel.Application")
'You do not need to make the application object visible
'if you close the file and quit the application
'later in your code, in order to remove these objects
'from memory.
With xlApp
.Visible = True
'START eerste tabel invoegen uit excel invoegen in Word
Path = "C:\spss\tabel\tabel006.xls"
.Workbooks.Open Path
.Range("A7:C10").Select
.Selection.Copy
Selection.PasteExcelTable False, False, False
'Prevent Excel from prompting to save changes
'to the workbook when the user quits.
.ActiveWorkbook.Saved = True
.ActiveWorkbook.Close
'EINDE eerste tabel invoegen uit excel invoegen in Word
.Quit
End With
End Sub
Sub Macro10_4()
'Zoeken van tabel004
Selection.Find.ClearFormatting
With Selection.Find
.Text = "{{tabel004}}"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
'Excel starten en wokrbook openen
Set xlApp = CreateObject("Excel.Application")
'You do not need to make the application object visible
'if you close the file and quit the application
'later in your code, in order to remove these objects
'from memory.
With xlApp
.Visible = True
'START eerste tabel invoegen uit excel invoegen in Word
Path = "C:\spss\tabel\tabel004.xls"
.Workbooks.Open Path
.Range("A9:E10").Select
.Selection.Copy
Selection.PasteExcelTable False, False, False
'Prevent Excel from prompting to save changes
'to the workbook when the user quits.
.ActiveWorkbook.Saved = True
.ActiveWorkbook.Close
'EINDE eerste tabel invoegen uit excel invoegen in Word
.Quit
End With
End Sub
ik gebruik volgende code om vanuit word excel tabellen in het word document te plaatsen (deed het perfect in 2003)
de eerste, Macro10 doet het nog
de tweede Macro10_4 doet het niet
er wordt een compileerfout aangegeven bij path: de tekst erbij is kan niet toewijzen aan een alleen-lezen eigenschap.
Voor mij lijken de twee codes identiek?
alvast bedankt
Nico
Sub Macro10()
'
Dim Path
'Zoeken van tabel001
Selection.Find.ClearFormatting
With Selection.Find
.Text = "{{tabel006}}"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
'Excel starten en wokrbook openen
Set xlApp = CreateObject("Excel.Application")
'You do not need to make the application object visible
'if you close the file and quit the application
'later in your code, in order to remove these objects
'from memory.
With xlApp
.Visible = True
'START eerste tabel invoegen uit excel invoegen in Word
Path = "C:\spss\tabel\tabel006.xls"
.Workbooks.Open Path
.Range("A7:C10").Select
.Selection.Copy
Selection.PasteExcelTable False, False, False
'Prevent Excel from prompting to save changes
'to the workbook when the user quits.
.ActiveWorkbook.Saved = True
.ActiveWorkbook.Close
'EINDE eerste tabel invoegen uit excel invoegen in Word
.Quit
End With
End Sub
Sub Macro10_4()
'Zoeken van tabel004
Selection.Find.ClearFormatting
With Selection.Find
.Text = "{{tabel004}}"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
'Excel starten en wokrbook openen
Set xlApp = CreateObject("Excel.Application")
'You do not need to make the application object visible
'if you close the file and quit the application
'later in your code, in order to remove these objects
'from memory.
With xlApp
.Visible = True
'START eerste tabel invoegen uit excel invoegen in Word
Path = "C:\spss\tabel\tabel004.xls"
.Workbooks.Open Path
.Range("A9:E10").Select
.Selection.Copy
Selection.PasteExcelTable False, False, False
'Prevent Excel from prompting to save changes
'to the workbook when the user quits.
.ActiveWorkbook.Saved = True
.ActiveWorkbook.Close
'EINDE eerste tabel invoegen uit excel invoegen in Word
.Quit
End With
End Sub