PC Review


Reply
Thread Tools Rate Thread

Business Objects and Excel

 
 
Hussain
Guest
Posts: n/a
 
      15th Nov 2006
I have a Business Object Report that outputs to an Excel spreadsheet. I
want to format the spreadsheet and save it before sending it out to
users.

The problem I have is that when I finish with the formatting, I cannot
close the Excel Application. It also asks me if I want to save the
file, when I go the the Excel Application. Below is the code I am
using.

Could anybody olease help?

Sub EmailReport()

On Error GoTo Emsg

Dim doc As Document
Dim body As String
Dim ReportName As String
Dim locPath As String
Dim objExcel As Object
Dim myObjExcel As Excel.Worksheet
Dim myObjWorkBook As Excel.Workbooks

dDate = Format((Now() - 27), "mmmm dd, YYYY")

Set doc = ActiveDocument
doc.Refresh



' Set objExcel = GetObject(, "Excel.Application")

' Set objExcel = GetObject(ActiveDocument)





locPath = "\\Fpptc01vgc02\O_drive\Sales\DomSales\Private\Sales
Reporting\"
ReportName = ActiveDocument.Name & ".xls"

'myObjWorkBook.Open
("\\Fpptc01vgc02\O_drive\Sales\DomSales\Private\Sales
Reporting\ActiveDocument.Name")


doc.SaveAs (locPath & "\" & ReportName & ".xls")
'-----------------------------------------------------
'Deleteing old report
'------------------------------------------------------------
MsgBox ReportName
'Kill locPath & "\" & ReportName & ".xls"


GetExcel
'-----------------------------------------------------
'Saving report
'------------------------------------------------------------



'------------------------------------------------------------
'Send via Outlook
'------------------------------------------------------------








Set EmailApp = CreateObject("Outlook.Application")

'Logon to Outlook using specified Profile
EmailProf.Logon "MS Exchange Settings", , False, False
Set EmailProf = EmailApp.GetNameSpace("MAPI")
EmailProf.Logon "MS Exchange Settings", , False, False

'Create new mail item
Set NewMail = EmailApp.CreateItem(olMailItem)

'Set Addressees, Subject & Body of message, Attachments, and Send
' . Separate multiple entries with semicolons

With NewMail
.To = "Hussaini-(E-Mail Removed)"

'.Cc = ""

' Load default message.
.body = "Attached is the report for : " & dDate
.Subject = doc.Name
.Importance = 1
.Attachments.Add (locPath & "\" & ReportName & ".xls")
.Send
End With

Set EmailApp = Nothing

Exit Sub

Emsg:

Open "\\Fpptc01vgc02\O_drive\Sales\DomSales\Private\Sales
Reporting\Scheduled Reports\Temp\Global-error.txt" For Output As #1
Print #1, Err.Number; Err.Description

MsgBox Err.Number & " " & Err.Description
Close #1

End Sub

Sub GetExcel()
Dim MyXL As Object
Dim ExcelWasNotRunning As Boolean
Dim ExcelSheet As Excel.Worksheet

On Error Resume Next
Set MyXL = GetObject(, "Excel.Application")
If Err.Number <> 0 Then ExcelWasNotRunning = True
Err.Clear

Set MyXL = CreateObject("Excel.Application")
' MyXL.Application.Visible = True

'DetectExcel

Set MyXL = GetObject("O:\Sales\DomSales\Private\Sales
Reporting\Email Reporting.xls")
Dim myRange As Integer

myRange = 33
'myExcel.

MyXL.Application.Visible = True
MyXL.Parent.Windows(1).Visible = True
MyXL.Application.Sheets(1).Range("A1:A2000").Delete =
True
MyXL.Application.Sheets(1).Range("A3:H7").Font.Bold =
True
'MyXL.Application.Sheets(1).Range("J3:J3").Cut
'MyXL.Application.Sheets(1).Range("A3:A3").Paste
'Move Company Name
MyXL.Application.Sheets(1).Range("A3:A3").Value =
MyXL.Application.Sheets(1).Range("J3:J3").Value
MyXL.Application.Sheets(1).Range("J3:J3").Value = ""
'Move Print Date and Time
MyXL.Application.Sheets(1).Range("G6:G6").Value =
MyXL.Application.Sheets(1).Range("J6:J6").Value
MyXL.Application.Sheets(1).Range("J6:J6").Value = ""
MyXL.Application.Sheets(1).Range("A6:A6").Value =
MyXL.Application.Sheets(1).Range("M6:M6").Value
MyXL.Application.Sheets(1).Range("M6:M6").Value = ""
MyXL.Application.Sheets(1).Save
MyXL.Apllication.Sheets(1).Close
Set MyXL = Nothing
MyXL.Application.Close
MyXL.Application.Quit



End Sub

 
Reply With Quote
 
 
 
 
susiedba@hotmail.com
Guest
Posts: n/a
 
      20th Nov 2006
you should be using SQL Server Reporting Services; sorry; Business
Objects is a scam

-Aaron


Hussain wrote:
> I have a Business Object Report that outputs to an Excel spreadsheet. I
> want to format the spreadsheet and save it before sending it out to
> users.
>
> The problem I have is that when I finish with the formatting, I cannot
> close the Excel Application. It also asks me if I want to save the
> file, when I go the the Excel Application. Below is the code I am
> using.
>
> Could anybody olease help?
>
> Sub EmailReport()
>
> On Error GoTo Emsg
>
> Dim doc As Document
> Dim body As String
> Dim ReportName As String
> Dim locPath As String
> Dim objExcel As Object
> Dim myObjExcel As Excel.Worksheet
> Dim myObjWorkBook As Excel.Workbooks
>
> dDate = Format((Now() - 27), "mmmm dd, YYYY")
>
> Set doc = ActiveDocument
> doc.Refresh
>
>
>
> ' Set objExcel = GetObject(, "Excel.Application")
>
> ' Set objExcel = GetObject(ActiveDocument)
>
>
>
>
>
> locPath = "\\Fpptc01vgc02\O_drive\Sales\DomSales\Private\Sales
> Reporting\"
> ReportName = ActiveDocument.Name & ".xls"
>
> 'myObjWorkBook.Open
> ("\\Fpptc01vgc02\O_drive\Sales\DomSales\Private\Sales
> Reporting\ActiveDocument.Name")
>
>
> doc.SaveAs (locPath & "\" & ReportName & ".xls")
> '-----------------------------------------------------
> 'Deleteing old report
> '------------------------------------------------------------
> MsgBox ReportName
> 'Kill locPath & "\" & ReportName & ".xls"
>
>
> GetExcel
> '-----------------------------------------------------
> 'Saving report
> '------------------------------------------------------------
>
>
>
> '------------------------------------------------------------
> 'Send via Outlook
> '------------------------------------------------------------
>
>
>
>
>
>
>
>
> Set EmailApp = CreateObject("Outlook.Application")
>
> 'Logon to Outlook using specified Profile
> EmailProf.Logon "MS Exchange Settings", , False, False
> Set EmailProf = EmailApp.GetNameSpace("MAPI")
> EmailProf.Logon "MS Exchange Settings", , False, False
>
> 'Create new mail item
> Set NewMail = EmailApp.CreateItem(olMailItem)
>
> 'Set Addressees, Subject & Body of message, Attachments, and Send
> ' . Separate multiple entries with semicolons
>
> With NewMail
> .To = "Hussaini-(E-Mail Removed)"
>
> '.Cc = ""
>
> ' Load default message.
> .body = "Attached is the report for : " & dDate
> .Subject = doc.Name
> .Importance = 1
> .Attachments.Add (locPath & "\" & ReportName & ".xls")
> .Send
> End With
>
> Set EmailApp = Nothing
>
> Exit Sub
>
> Emsg:
>
> Open "\\Fpptc01vgc02\O_drive\Sales\DomSales\Private\Sales
> Reporting\Scheduled Reports\Temp\Global-error.txt" For Output As #1
> Print #1, Err.Number; Err.Description
>
> MsgBox Err.Number & " " & Err.Description
> Close #1
>
> End Sub
>
> Sub GetExcel()
> Dim MyXL As Object
> Dim ExcelWasNotRunning As Boolean
> Dim ExcelSheet As Excel.Worksheet
>
> On Error Resume Next
> Set MyXL = GetObject(, "Excel.Application")
> If Err.Number <> 0 Then ExcelWasNotRunning = True
> Err.Clear
>
> Set MyXL = CreateObject("Excel.Application")
> ' MyXL.Application.Visible = True
>
> 'DetectExcel
>
> Set MyXL = GetObject("O:\Sales\DomSales\Private\Sales
> Reporting\Email Reporting.xls")
> Dim myRange As Integer
>
> myRange = 33
> 'myExcel.
>
> MyXL.Application.Visible = True
> MyXL.Parent.Windows(1).Visible = True
> MyXL.Application.Sheets(1).Range("A1:A2000").Delete =
> True
> MyXL.Application.Sheets(1).Range("A3:H7").Font.Bold =
> True
> 'MyXL.Application.Sheets(1).Range("J3:J3").Cut
> 'MyXL.Application.Sheets(1).Range("A3:A3").Paste
> 'Move Company Name
> MyXL.Application.Sheets(1).Range("A3:A3").Value =
> MyXL.Application.Sheets(1).Range("J3:J3").Value
> MyXL.Application.Sheets(1).Range("J3:J3").Value = ""
> 'Move Print Date and Time
> MyXL.Application.Sheets(1).Range("G6:G6").Value =
> MyXL.Application.Sheets(1).Range("J6:J6").Value
> MyXL.Application.Sheets(1).Range("J6:J6").Value = ""
> MyXL.Application.Sheets(1).Range("A6:A6").Value =
> MyXL.Application.Sheets(1).Range("M6:M6").Value
> MyXL.Application.Sheets(1).Range("M6:M6").Value = ""
> MyXL.Application.Sheets(1).Save
> MyXL.Apllication.Sheets(1).Close
> Set MyXL = Nothing
> MyXL.Application.Close
> MyXL.Application.Quit
>
>
>
> End Sub


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
I am using excel 2002 with the business objects addin for Infoview Sarah H Pearson Microsoft Excel New Users 0 27th Oct 2009 05:04 PM
Run Business Objects Report from Excel using VBA ferret Microsoft Excel Programming 5 22nd Aug 2007 01:20 PM
OT: Business Objects - what are they and can they contain objects like sockets? g18c@hotmail.com Microsoft C# .NET 1 20th Jan 2006 07:12 PM
100% Free MS Access .NET Code Generator (tired of hand cranking business objects/data objects) ? MyGeneration Microsoft Access 0 27th Jan 2005 04:55 AM
Re: Connect Business Objects to Excel with DDE eggman Microsoft Excel Misc 0 24th Aug 2004 04:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:28 PM.