Word/Excel Insert Single Worksheet from Workbook 
Author Message
 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



Fri, 07 Jan 2005 00:03:58 GMT  
 Word/Excel Insert Single Worksheet from Workbook
Hi Dg,

In that case, you'd better post in the excel.programming newsgroup. You'll
find the occasional person who knows something about Excel here, in this
MSWORD VBA newsgroup. But the experts are in the Excel NGs :-)

Quote:
> 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.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.mvps.org/word
http://go.compuserve.com/MSOfficeForum

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)



Fri, 07 Jan 2005 16:21:27 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How can I open Excel workbook without using Excel.Worksheet

2. Controling an inserted Excel worksheet in Word

3. H2 insert new XL worksheet incl data into existing XL workbook

4. deleting worksheet in excel workbook

5. function to see if an Excel worksheet name exitsts in a workbook

6. processing excel rows - separate workbooks/worksheets

7. Excel - Use the current workbook and worksheet

8. detect the worksheet-names in an EXCEL 5.0 workbook

9. Excel Workbook vs. Worksheet

10. wsh/vba for excel automation: moving worksheets beetween workbooks

11. Accessing a worksheet in an Excel workbook

12. Save a Worksheet in Excel to a Master Workbook

 

 
Powered by phpBB® Forum Software