
Word/Excel Insert Single Worksheet from Workbook
Am looking for some expert advice on a
VBA programming problem I am having.
I have a single Excel workbook with multiple worksheets. I'd like to insert
different worksheets from the same workbook at different places in my word
document. I need to keep them linked to the original excel workbook. Is
there a way to do this using VBA or do I need to create multiple copies of
the workbook?
My insertion code looks like:
Private Function InsertLandValueSpreadsheet()
If ActiveDocument.Bookmarks.Exists("bkLandValueSpreadsheet") = True Then
Dim rngLandSpreadsheet As Range
Set rngLandSpreadsheet =
ActiveDocument.Bookmarks("bkLandValueSpreadsheet").Range
Dim LandSpreadsheetFileName As String
Dim fso As Scripting.FileSystemObject
Set fso = New Scripting.FileSystemObject
If fso.FileExists(ActiveDocument.Variables("varAppraisalFolder") & _
ActiveDocument.Variables("varAppraisalName") & ".xls") = "True" Then
LandSpreadsheetFileName =
(ActiveDocument.Variables("varAppraisalFolder") & _
ActiveDocument.Variables("varAppraisalName") & ".xls")
ActiveDocument.InlineShapes.AddOLEObject
FileName:=LandSpreadsheetFileName, _
LinktoFile:=True, Range:=rngLandSpreadsheet
Else
MsgBox ((ActiveDocument.Variables("varAppraisalFolder") & _
ActiveDocument.Variables("varAppraisalName") & ".xls") & _
"Land value spreadsheet file does not exist")
End If
Set fso = Nothing
Else
MsgBox ("Land value spreadsheet bookmark does not exist")
End If
End Function
Thanks in advance for any help you can provide.
Regards,
Dave Gaines