Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello Everyone,
I used the Import external data function to bring a single table from my MSSQL database into a spreadsheet as a tab of the sheet. When I open the workbook by clicking on it or by going to it in the list of recent files everything opens correctly. A pop up window asks me if I want to update the data or not. Clicking yes populates the tab with the table and clicking no leaves the tab blank. Now then, I am using VB to open the spreadsheet from another program. I have placed a button on the form in that sheet. The workbook must be opened as an object. When I open from there I am not asked if I want to update the way that I am asked by opening otherwise. Below is the code that open the workbook from our MRP program. Private Function OpenQUOTEWorksheet() As Boolean On Error GoTo OpenQWSError If loadFileName = "" Then loadFileName = GetFileOfType("Excel", "xls") End If If loadFileName < "" Then If oExcel Is Nothing Then Set oExcel = CreateObject("Excel.Application") Else Set oExcel = GetObject(, "Excel.Application") End If Set oBook = oExcel.Workbooks.Open(loadFileName) Set oSheet = oBook.Worksheets(sheetName) oExcel.Visible = True OpenQUOTEWorksheet = True Else MsgBox "No Quote Worksheet Selected." OpenQUOTEWorksheet = False End If Exit Function OpenQWSError: MsgBox ("Error: " & Err.Number & "- " & Err.Description & ". Worksheet not opened.") Err.Clear OpenQUOTEWorksheet = False End Function Now, I have to open the workbook this way. It is due to the way that the MRP program is running. Therefore, I need the workbook to refresh the connection after it is open. How would any of you go about making this happen? I was thinking of adding a VB command into the ThisWorkBook portion to cause it to go out when the sheet is opened. Oh yeah, I also had a combo box that populated with a list when the book opened. The population was written into a module. Opening this way caused that to not work either. I fixed it by placing the code into the ThisWorkBook section as a Private Sub Workbook_Open(). That is why I was thinking that pointing a query at the table from here might be the solution. So what is the best way to write the query into a Private Sub Workbook_Open()? Thanks for any help, LWhite |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I import a database from excel 2003 to 2007? | New Users to Excel | |||
How do I import the pivot table wizard into Excel (2003)? | Excel Discussion (Misc queries) | |||
How do I import my fill color table from Excel 2003 into Excel 200 | Setting up and Configuration of Excel | |||
2003 - import external data problem | Excel Discussion (Misc queries) | |||
database query not showing foxpro database How I import data | New Users to Excel |