Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default New to VBS and MSSql

Hi all.. Need a little help please...

I have a nice formatted report that I have used the "New Database Query"
wizard to populate the worksheet from a few SQL tables and it works great! I
have two problems:

1.) This report is opened and then saved as another file name manually.
When the report is opened by anyone without acces to the data source, no
info! It tries to run the query by design.

2.) I need for the file to save as the date & time with the current SQL data
instead of the query as an .xls file (my current script saves it as an .html
file or tries to).

Here is what I have so far:

Dim oExcel
Dim gfuncs
Dim oBook
sSourceFile = "C:\Documents and Settings\Administrator\Application
Data\Microsoft\Templates\Book2.xlt"

sOutputFile = "C:\CD\Support\Scripts\" & Month(date()) & "-" & Day(date())
& "-" & year(date()) & "_Current.xls"

Set gfuncs = CreateObject("uisupport.globalfunctions")
installpath = gfuncs.getinstallpath

Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = False

oExcel.Workbooks.Add sSourceFile

oExcel.Workbooks(1).SaveAs sOutputFile, 44

oExcel.Workbooks.Close
oExcel.Quit
Set wBook = Nothing
Set oExcel = Nothing


This would work perfect if it would simply put the data from the query in
there instead of the query itself.

Any ideas?

Thanks all!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default New to VBS and MSSql

It looks as if you're creating a new workbook based on a template
(Book2.xlt) and saving it. How can there be any data in it to save?
--
Jim Rech
Excel MVP
"Robby" wrote in message
...
| Hi all.. Need a little help please...
|
| I have a nice formatted report that I have used the "New Database Query"
| wizard to populate the worksheet from a few SQL tables and it works great!
I
| have two problems:
|
| 1.) This report is opened and then saved as another file name manually.
| When the report is opened by anyone without acces to the data source, no
| info! It tries to run the query by design.
|
| 2.) I need for the file to save as the date & time with the current SQL
data
| instead of the query as an .xls file (my current script saves it as an
..html
| file or tries to).
|
| Here is what I have so far:
|
| Dim oExcel
| Dim gfuncs
| Dim oBook
| sSourceFile = "C:\Documents and Settings\Administrator\Application
| Data\Microsoft\Templates\Book2.xlt"
|
| sOutputFile = "C:\CD\Support\Scripts\" & Month(date()) & "-" &
Day(date())
| & "-" & year(date()) & "_Current.xls"
|
| Set gfuncs = CreateObject("uisupport.globalfunctions")
| installpath = gfuncs.getinstallpath
|
| Set oExcel = CreateObject("Excel.Application")
| oExcel.Visible = False
|
| oExcel.Workbooks.Add sSourceFile
|
| oExcel.Workbooks(1).SaveAs sOutputFile, 44
|
| oExcel.Workbooks.Close
| oExcel.Quit
| Set wBook = Nothing
| Set oExcel = Nothing
|
|
| This would work perfect if it would simply put the data from the query in
| there instead of the query itself.
|
| Any ideas?
|
| Thanks all!!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default New to VBS and MSSql

Thanks for the reply Jim. That is really my question. I use the data query
to populate the tables for the report when Excel opens the file.

"Jim Rech" wrote:

It looks as if you're creating a new workbook based on a template
(Book2.xlt) and saving it. How can there be any data in it to save?
--
Jim Rech
Excel MVP
"Robby" wrote in message
...
| Hi all.. Need a little help please...
|
| I have a nice formatted report that I have used the "New Database Query"
| wizard to populate the worksheet from a few SQL tables and it works great!
I
| have two problems:
|
| 1.) This report is opened and then saved as another file name manually.
| When the report is opened by anyone without acces to the data source, no
| info! It tries to run the query by design.
|
| 2.) I need for the file to save as the date & time with the current SQL
data
| instead of the query as an .xls file (my current script saves it as an
..html
| file or tries to).
|
| Here is what I have so far:
|
| Dim oExcel
| Dim gfuncs
| Dim oBook
| sSourceFile = "C:\Documents and Settings\Administrator\Application
| Data\Microsoft\Templates\Book2.xlt"
|
| sOutputFile = "C:\CD\Support\Scripts\" & Month(date()) & "-" &
Day(date())
| & "-" & year(date()) & "_Current.xls"
|
| Set gfuncs = CreateObject("uisupport.globalfunctions")
| installpath = gfuncs.getinstallpath
|
| Set oExcel = CreateObject("Excel.Application")
| oExcel.Visible = False
|
| oExcel.Workbooks.Add sSourceFile
|
| oExcel.Workbooks(1).SaveAs sOutputFile, 44
|
| oExcel.Workbooks.Close
| oExcel.Quit
| Set wBook = Nothing
| Set oExcel = Nothing
|
|
| This would work perfect if it would simply put the data from the query in
| there instead of the query itself.
|
| Any ideas?
|
| Thanks all!!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2002, MS Query and MSSQL View with periods John T in MD Excel Discussion (Misc queries) 0 March 14th 07 02:06 PM
Resource of excel to connection mssql to get data Joe Excel Programming 4 July 31st 04 07:59 PM
SQLRequest to MSSQL server - macro chuckiej Excel Programming 2 May 13th 04 04:28 PM
SQL.REQUEST query omitting rows in MSSQL DB Steve Remer Excel Programming 2 February 17th 04 05:25 PM


All times are GMT +1. The time now is 05:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"