Hello
this code i used in 2003 version to past excel tables in to a word document
the first code works in 2010
the next doesn't anymore: compilation error: read only.
What could be wrong? The two codes look the same?
Thanks
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
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
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
.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
.Quit
End With
End Sub
this code i used in 2003 version to past excel tables in to a word document
the first code works in 2010
the next doesn't anymore: compilation error: read only.
What could be wrong? The two codes look the same?
Thanks
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
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
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
.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
.Quit
End With
End Sub