Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 86,371 VB Programmers. There are 1,470 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a VB Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

Viewing Excel sheet within another program

 
Reply to this topicStart new topic

Viewing Excel sheet within another program

Nicksort
post 6 May, 2008 - 11:04 AM
Post #1


New D.I.C Head

*
Joined: 5 May, 2008
Posts: 2



I am a self taught wannabe that is lost, I have aided the help of the company in house programers and no one has been able to answer my question, maybe someone here can, I hope so.....
I am the manager of a Mechanical Design team for a company and I have managed to put toghter a few small helpful tools for everyone to use. I have included a picture of the latest one I am working on and you will see the task I gave myself to accomplish. In the picture, you will see 3 excel sheet inserts. When my designers are using this tool which inputs information into drawings and solid models, they are switching back and forth from different excel sheets for the information to input.
I am trying to get this task shortened by including an excel window that the designer can view within this tool.
That is my problem, I have beat myself up for a week and I cannot come up with the correct result. Here is the picture of the tool we use and a partial snippit of the code. You can see the 3 different codes I have tried to get to work and there have been many other trys also. I have named the excel file to open C:\CPTest1.XLS.
What am I doing wrong?
Any help will be appreciated, thanks, Nick




CODE
Private Sub Spreadsheet1_BeforeContextMenu(ByVal x As Long, ByVal y As Long, ByVal Menu As OWC11.ByRef, ByVal Cancel As OWC11.ByRef)
End Sub
Public Sub test()
Dim myXl As Object
myXl = GetObject("C:\CPTest1.XLS")
Spreadsheet1 = myXl
End Sub



CODE

Sub GetExcel()
    Dim myXl As Object    ' Variable to hold reference
                                ' to Microsoft Excel.
    Dim ExcelWasNotRunning As Boolean    ' Flag for final release.

' Test to see if there is a copy of Microsoft Excel already running.
    On Error Resume Next    ' Defer error trapping.
' Getobject function called without the first argument returns a
' reference to an instance of the application. If the application isn't
' running, an error occurs.
    Set myXl = GetObject(, "Excel.Application")
    If Err.Number <> 0 Then ExcelWasNotRunning = True
    Err.Clear    ' Clear Err object in case error occurred.

' Check for Microsoft Excel. If Microsoft Excel is running,
' enter it into the Running Object table.
    DetectExcel

' Set the object variable to reference the file you want to see.
    Set myXl = GetObject("C:\CPTest1.xls")

' Show Microsoft Excel through its Application property. Then
' show the actual window containing the file using the Windows
' collection of the MyXL object reference.
    myXl.Application.Visible = True
    myXl.Parent.Windows(1).Visible = True
     'Do manipulations of your  file here.
    ' ...
' If this copy of Microsoft Excel was not running when you
' started, close it using the Application property's Quit method.
' Note that when you try to quit Microsoft Excel, the
' title bar blinks and a message is displayed asking if you
' want to save any loaded files.
    If ExcelWasNotRunning = True Then
        myXl.Application.Quit
    End If

    Set myXl = Nothing    ' Release reference to the
                                ' application and spreadsheet.
End Sub


CODE

Private Sub Spreadsheet3_BeforeContextMenu(ByVal x As Long, ByVal y As Long, ByVal Menu As OWC10.ByRef, ByVal Cancel As OWC10.ByRef)
' Start Microsoft Excel and open an existing Worksheet object.
Set ExcelWorksheet = GetObject("C:\CPTest1.xls")
End Sub


This post has been edited by Nicksort: 6 May, 2008 - 11:09 AM


Attached thumbnail(s)
Attached Image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


Nicksort
post 7 May, 2008 - 08:30 AM
Post #2


New D.I.C Head

*
Joined: 5 May, 2008
Posts: 2



anyone???????

This post has been edited by Nicksort: 7 May, 2008 - 08:32 AM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 5/17/08 02:34AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month