Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default run the macros without opening or showing the excel sheet


Hi Frank
Thanks for your reply ....

I tried this . It'w orking fine ..But still i have one problem. When
schedule it , it showing up for a second ..and it's quiting . Can w
avoid that ..? Also i have a question..if we want to edit that macro
how we can open that ....Since i have set it as "running macros whil
opening workbook .."

Basically i am checking already existing sheet values with databs
output ..and if it different it has to send an email .
I have included the application.displayalerts ......and all in th
mainfunction ...
sub auto _open ..


CAn u please tell me ..?



Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim data As Worksheet


Sub Auto_open()
Application.displayalerts =false
Set data = Application.Worksheets("DATA")
Call setupConnections
Call populatedata
Worksheets("DATA").Activate
If cn.State = 1 Then cn.Close
Activeworkbook.save
Application.quit
End Sub

Function populatedata()

Dim mymail As New CDONTS.NewMail
Worksheets("DATA").Activate
ActiveSheet.Range("A2:Z1000").Activate
Dim ws As Worksheet
Selection.ClearContents

Dim sql As String
sql = "select distinct mkt_nam from hist_frmly_lives"
Set rs = CreateObject("ADODB.Recordset")

If rs.State = 1 Then rs.Close
rs.Open sql, cn

' On Error Resume Next
' ActiveSheet.Range("DATA").Select
Do While Not rs.EOF
Count = 0
For Each CellVal In rs.Fields

Err.Clear

ActiveCell.Value = rs(Count)

If Err.Number < 0 Then ActiveCell.Value
rs.Fields(Count)

ActiveCell.Offset(0, 1).Select
Count = Count + 1
Next
ActiveCell.Offset(1, -Count).Select
rs.movenext
Loop

lr1 = Worksheets("ACTUAL").UsedRange.Rows.Count
lr2 = Worksheets("DATA").UsedRange.Rows.Count

If lr1 < lr2 Then

mymail.From = "
mymail.To = "
mymail.Subject = "Test"
mymail.Body = "sheets are different"
mymail.Send
Set mymail = Nothing




Else

For r = 2 To lr1
cf1 = ""
cf2 = ""
On Error Resume Next
cf1 = Worksheets("DATA").Cells(r, 1).FormulaLocal
cf2 = Worksheets("ACTUAL").Cells(r, 1).FormulaLocal
On Error GoTo 0
If cf1 < cf2 Then

mymail.From = "
mymail.To = "
mymail.Subject = "Test"
mymail.Body = "sheets are different"
mymail.Send
Set mymail = Nothing


Exit For
End If
Next r

End If

On Error GoTo 0
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing



End Function

Function setupConnections()
cn.Open "ppgp.ppg.pfizer.comdsn", "ops$pyrcmdw", "pyrcmdw03"
cn.CursorLocation = adUseClient
End Functio

--
ps
-----------------------------------------------------------------------
psk's Profile: http://www.excelforum.com/member.php...fo&userid=1573
View this thread: http://www.excelforum.com/showthread.php?threadid=27334

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
opening a worksheet without showing excel components bigdaddy3 Excel Worksheet Functions 2 August 11th 05 11:03 AM
Message "class not registered" opening sheet with macros Excel 97 PlanetSavers Excel Discussion (Misc queries) 1 July 4th 05 06:48 PM
run the macros without opening or showing the excel sheet psk[_4_] Excel Programming 1 October 28th 04 08:11 PM
macros not showing up when using excel COM object in .NET Priya[_3_] Excel Programming 1 August 26th 04 05:19 PM
Excel VBA question - showing userform when opening workbook ajliaks Excel Programming 2 April 12th 04 06:24 PM


All times are GMT +1. The time now is 12:23 AM.

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"