Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Powerpoint Code To Close Excel File Working Incorrectly


Hello,

I am trying to automate a process that runs an access query, transfers the spreadsheet to an excel page, populates charts and graphs, and then uses these charts and graphs with other formatting to create PowerPoint slides.

Although my code seems to work well, when I log off the computer I am prompted to save changes for an "open" excel file, although it doesn't appear to be open. I think this is creating problems with my transferspreadhseet function in Access, because I am getting the error message "Too Many Fields Defined".

Here is a sample of my ppt code:

Set xlApp = CreateObject("Excel.Application")
Set xlWrkBook = xlApp.Workbooks.Open("\Sfa19pmd$ReportingPatient Reporting - TSIPatient Financial ReportingTemplate DatabasesCharts Master template.xls")

' Create a new slide
ActiveWindow.View.GotoSlide Index:=ActivePresentation.Slides.Add(Index:=1, Layout:=ppLayoutTitleOnly).SlideIndex

' Copy picture of the 1st chart object onto the clipboard
xlWrkBook.Worksheets("IP Variance Chart").ChartObjects("IP Variance Chart").Chart.CopyPicture

and so on.... until I reach the end of my code:

' Close the open workbook without saving changes
xlWrkBook.Close (False)
xlApp.Quit

Set xlApp = Nothing
Set xlWrkBook = Nothing

I a wondering if I am opening the Excel file too many times and am missing code that would work better??

Your help is so much appreciated!!
Thanks




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Whats The Vb Code To Close Excel Within Excel Using A Macro
i need the code to close excel within excel using a macro and saving all of the changes.


please help//


Jas

How To Use Code Insert Picture Into Powerpoint File
Currently I can use code insert shape into a powerpoint file. But which function is for insert picture?

Thanks

File Signature Of Word/excel/powerpoint
Does anyone know how to deal with the file signature of word/excel/powerpoint?

They all have a common signature of D0 CF 11 E0 A1 B1 1A E1 but I want to find out who's who among them.

Code Not Working To Open Excel:
Hello... I follwed the guide closely for OLE automation and the code is bombing where I'm trying to write values to excel. i'm gettign the error that the method or variable is not defined??


Code:
Private Sub Command4_Click()
Dim oExcel As Excel.Application
Dim oWB As Excel.Workbook
Dim oWS As Excel.Worksheet

Set oExcel = New Excel.Application
Set oWS = oExcel.ActiveSheet
oExcel.Visible = False
oExcel.DisplayAlerts = False

oWS.Cells(1, 1) = "Total Time in Production" '<------ Bombs here
oWS.Cells(1, 2) = TotalInterval1

oWS.Cells(2, 1) = "Total Time in Scrap"
oWS.Cells(2, 2) = TotalInterval2

oWS.Cells(3, 1) = "Total Time Purging"
oWS.Cells(3, 2) = TotalInterval3

'Cleanup
On Error Resume Next
oExcel.DisplayAlerts = False
Call oWB.Close(SaveChanges:=True)
Set oWB = Nothing
oExcel.Quit
Set oExcel = Nothing

End Sub

My Excel Formatting Code Is Not Working...
Good Afternoon,

We have an ad hoc reporting application that retrieves data from a MSSQL database and allows the user to export the recordset to Excel. After making a change and updating some of our users, they pointed out that it now formats the quantity as a dollar amount when exporting to Excel. I found the cause of that and in the process of correcting it I also noticed that one of the fields that we could return is gross margin percentage (GM%) and I attempted to make the formatting change for that field as well. Unfortunately my change has not worked completely. The column reflects that it should show a percentage value (0.00%), buy it still displays the value as a straight decimal (.1619 instead of 16.19%). If I enter that cell (double-click) and then hit return - presto magico - it shows 16.19% as I would like it to. Perhaps what I am looking for is an column activation of sorts (.Activate only seems to highlight the column). Anyway, here is the code with the section in red being the lines where I expected it to work.

Thanks for your time,

-Scott


Code:
Dim db As dao.Database
Dim rs As dao.Recordset
Dim ix As Integer
Dim intMaxCol As Integer
Dim intMaxRow As Integer
Dim objXL As Excel.Application
Dim objWkb As Workbook
Dim objSht As Worksheet
Set db = OpenDatabase(App.Path & "" & gsAccessDB)
Set rs = db.OpenRecordset("tblResults")
  intMaxCol = rs.Fields.Count
  If rs.RecordCount > 0 Then
    rs.MoveLast: rs.MoveFirst
    intMaxRow = rs.RecordCount
    Set objXL = New Excel.Application
    With objXL
      .Visible = True
      Set objWkb = .Workbooks.Add
      Set objSht = objWkb.Worksheets(1)
      With objSht

        For ix = 0 To rs.Fields.Count - 1
            .Cells(1, ix + 1).Value = rs.Fields(ix).Name
            
                'Added 1/11/05
                If UCase(DataType(rs.Fields(ix).Name)) = "MCDOUBLE" Then
                  ' If this is candidate for formatting, check options
                  Select Case rs.Fields(ix).Name
                    Case "Sales Dollars", "Cost Dollars", "Gross Margin", "Channel Chg", "Channel Forecast"
                      If gbOptionRoundThousands Then
                        If gbOptionExcelformat Then
                          .Columns(ix + 1).NumberFormat = "$#,##0,_)"
                        Else
                          .Columns(ix + 1).NumberFormat = "#0,_)"
                        End If
                      Else
                        If gbOptionExcelformat Then
                          .Columns(ix + 1).NumberFormat = "$#,###.00"
                        End If
                      End If
Case "GM%"
                      .Columns(ix + 1).NumberFormat = "0.00%"
                    Case Else
                      .Columns(ix + 1).NumberFormat = "General"
                  End Select
                End If

        Next ix
        'The next line simply formats the headers to bold font
        .Range(.Cells(1, 1), .Cells(1, rs.Fields.Count)).Font.Bold = True
        .Range(.Cells(2, 1), .Cells(intMaxRow, intMaxCol)).CopyFromRecordset rs
        .Columns.AutoFit
      End With
    End With
  End If
Set objSht = Nothing
Set objWkb = Nothing
Set objXL = Nothing
Set rs = Nothing
Set db = Nothing





Edited by - Geof on 1/22/2007 6:54:36 PM

Close Powerpoint
I have an application that brings up a power point presentation when a button is pressed. The user clicks throught the slides, and I'd like to have the presentation and application close after the screen that says 'end of slide show, click to exit'.
The way it is now, the presentation ends, but power point stays open. I've tried adding .presentapplication.close and .quit, but then the presentation only shows one slide and quits. I've also tried an if statement that closes and quits if it's the last slide, but that did absolutely nothing. I'm sure I have syntax and/or code placement wrong.
Any ideas on what to add to the code to get the office application to end would be great.
Here's my stripped down code (without the attempts to close and quit):

Private Sub cmdPPT_Click()
Dim ppApp As New PowerPoint.Application
ppApp.WindowState = ppWindowMaximized
ppApp.Visible = True
ppApp.Presentations.Open FileName:=Path, ReadOnly:=True
With ppApp.ActivePresentation.SlideShowSettings
.LoopUntilStopped = False
.RangeType = ppShowAll
.AdvanceMode = ppSlideShowManualAdvance
.Run
End With
Set ppApp = Nothing
End Sub

Can't Close Excel: Small Code Set Given Here Shows Complete Problem
discussed in great detail in the thread at:

http://www.vbforums.com/showthread....threadid=199211

I have reduced the problem down to a minimal code set given below. This code is the entire app. Reference Excel object (9.0 or 10.0) and put this in the load event of a blank form & just run the app. Here's what happens:

with task mgr, you'll see that there is no excel process prior to running the app, and when you run the app (which opens the form) task manager will show an excel process running. It SHOULDN'T be, since part of the code closes excel after having opened it. kill the app & excel closes, but it should have closed from the code at the end of the app.

If you comment out the chart creation code, then run the app, task manager will show you as excel opens and closes, but when you put the chart creation code in, excel opens, but never closes.
[vbcode]Option Explicit
'
' need to have, in the application path, an excel file called
' "book1.xls" and it has to have, in it's first worksheet
' (called "Sheet1") some numbers in the first 3 rows of the
' left-most column
'
Private Sub Form_Load()
Dim ch As ChartObject
Dim myObj1 As Object
Dim xlApp As Excel.Application
Dim xlsfilename As String

xlsfilename = App.Path & "ook1.xls"
Set xlApp = New Excel.Application
xlApp.Workbooks.Open xlsfilename
xlApp.Worksheets("Sheet1").Activate
Set ch = xlApp.ActiveSheet.ChartObjects.Add(100, 20, 250, 170)
ch.Chart.ChartType = xlPie
Set myObj1 = xlApp.ActiveSheet.Range(cells(1, 1), cells(3, 1))
ch.Chart.SetSourceData Source:=myObj1, PlotBy:=xlColumns
Set ch = Nothing
Set myObj1 = Nothing
xlApp.DisplayAlerts = False
xlApp.ActiveWorkbook.Close SaveChanges:=True, FileName:=xlsfilename
xlApp.DisplayAlerts = True
xlApp.Quit
Set xlApp = Nothing
Exit Sub
End Sub[/vbcode]

so, can anyone figure out how to get excel to close after creating the charts? all help greatly appreciated

Excel Automated Printing; API Code Not Working!
ARGH! I am trying to automate the printing of several worksheets in Excel using API. Ideally the user would give me their settings (duplex and color settings only) and I would automatically print each sheet individually.

I have taken some code found here (http://pubs.logicalexpressions.com/P...cle.asp?ID=116) but it was written for Word.

I cannot get my printer to respond to the changes. The code says its making changes (if you set a property, it stays set and you can read it back) but the printer prints the same (default) way everytime.

Code below, my test function is called BoxTest. Simple: set and print three times.


Code:
Option Explicit

Private Type PRINTER_DEFAULTS
pDatatype As Long
pDevmode As Long
DesiredAccess As Long
End Type

Private Type PRINTER_INFO_2
pServerName As Long
pPrinterName As Long
pShareName As Long
pPortName As Long
pDriverName As Long
pComment As Long
pLocation As Long
pDevmode As Long ' Pointer to DEVMODE
pSepFile As Long
pPrintProcessor As Long
pDatatype As Long
pParameters As Long
pSecurityDescriptor As Long ' Pointer to SECURITY_DESCRIPTOR
Attributes As Long
Priority As Long
DefaultPriority As Long
StartTime As Long
UntilTime As Long
Status As Long
cJobs As Long
AveragePPM As Long
End Type

Private Type DEVMODE
dmDeviceName As String * 32
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * 32
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
dmICMMethod As Long
dmICMIntent As Long
dmMediaType As Long
dmDitherType As Long
dmReserved1 As Long
dmReserved2 As Long
End Type

Private Const DM_ORIENTATION = &H1
Private Const DM_PAPERSIZE = &H2
Private Const DM_PAPERLENGTH = &H4
Private Const DM_PAPERWIDTH = &H8
Private Const DM_DEFAULTSOURCE = &H200
Private Const DM_PRINTQUALITY = &H400
Private Const DM_COLOR = &H800
Private Const DM_DUPLEX = &H1000

Private Const DM_IN_BUFFER = 8
Private Const DM_OUT_BUFFER = 2
Private Const PRINTER_ACCESS_USE = &H8
Private Const STANDARD_RIGHTS_REQUIRED = &HF0000
Private Const PRINTER_NORMAL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or _
PRINTER_ACCESS_USE)

Private Const PRINTER_ENUM_CONNECTIONS = &H4
Private Const PRINTER_ENUM_LOCAL = &H2

Private Declare Function EnumPrinters Lib "winspool.drv" Alias "EnumPrintersA" _
(ByVal flags As Long, ByVal name As String, ByVal Level As Long, _
pPrinterEnum As Long, ByVal cdBuf As Long, pcbNeeded As Long, _
pcReturned As Long) As Long

Private Declare Function PtrToStr Lib "kernel32" Alias "lstrcpyA" _
(ByVal RetVal As String, ByVal Ptr As Long) As Long

Private Declare Function StrLen Lib "kernel32" Alias "lstrlenA" _
(ByVal Ptr As Long) As Long

Private Declare Function ClosePrinter Lib "winspool.drv" _
(ByVal hPrinter As Long) As Long
Private Declare Function DocumentProperties Lib "winspool.drv" _
Alias "DocumentPropertiesA" (ByVal hwnd As Long, _
ByVal hPrinter As Long, ByVal pDeviceName As String, _
ByVal pDevModeOutput As Long, ByVal pDevModeInput As Long, _
ByVal fMode As Long) As Long
Private Declare Function GetPrinter Lib "winspool.drv" Alias _
"GetPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, _
pPrinter As Byte, ByVal cbBuf As Long, pcbNeeded As Long) As Long
Private Declare Function OpenPrinter Lib "winspool.drv" Alias _
"OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, _
pDefault As PRINTER_DEFAULTS) As Long
Private Declare Function SetPrinter Lib "winspool.drv" Alias _
"SetPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, _
pPrinter As Byte, ByVal Command As Long) As Long

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(pDest As Any, pSource As Any, ByVal cbLength As Long)
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Declare Function DeviceCapabilities Lib "winspool.drv" _
Alias "DeviceCapabilitiesA" (ByVal lpDeviceName As String, _
ByVal lpPort As String, ByVal iIndex As Long, lpOutput As Any, _
ByVal dev As Long) As Long


Sub BoxTest()
Dim printSet As PrinterSettings
Dim StrPrinters As Variant
Dim x, iDuplex, iColorMode As Long
Dim printerFlag As Boolean
Dim printer1, printer2 As Integer
Dim printer, sides, bandw, currentPrinter As String

SetDuplex (1)
SetColorMode (2)

Application.ActiveSheet.PrintOut

SetDuplex (2)
SetColorMode (1)

Application.ActiveSheet.PrintOut

SetDuplex (3)
SetColorMode (2)

Application.ActiveSheet.PrintOut


' StrPrinters = ListPrinters
'
' Set PrinterSettings = New PrinterSettings
' Set printSet = New PrinterSettings
' printSet.Caption = "Printing options"
'
' printerFlag = False
' For x = 0 To UBound(StrPrinters)
' currentPrinter = Mid(StrPrinters(x), 1, 6)
' If (StrComp(currentPrinter, "LANIER", vbTextCompare) = 0) Then
' printSet.OptionButton1.Caption = "The Lanier"
' printSet.OptionButton1.Visible = True
' printerFlag = True
' printer1 = x
' ElseIf (StrComp(currentPrinter, "\prin", vbTextCompare) = 0) Then
' printSet.OptionButton2.Caption = "Printer room HP"
' printSet.OptionButton2.Visible = True
' printerFlag = True
' printer2 = x
' End If
' Next x
'
' If printerFlag = False Then
' MsgBox ("No available printers. Please try again later.")
' Else
' printSet.OptionButton1.Value = True
' printSet.OptionButton5.Value = True
' printSet.OptionButton7.Value = True
' printSet.Show
' End If
'
' If printSet.TextBox1.Text = 1 Then
' printer = StrPrinters(printer1)
' Else
' printer = StrPrinters(printer2)
' End If
' sides = printSet.TextBox2.Text
' bandw = printSet.TextBox3.Text
'
' MsgBox (printer & ", " & sides & ", " & bandw)
'
' Unload printSet
'
' iDuplex = GetDuplex
' iColorMode = GetColorMode
'
' If StrComp(sides, "double", vbTextCompare) = 0 Then
' SetDuplex (3)
' Else
' SetDuplex (1)
' End If
'
' If StrComp(bandw, "bw", vbTextCompare) = 0 Then
' SetDuplex (1)
' Else
' SetDuplex (2)
' End If
'
' Application.ActiveSheet.PrintOut
'
' SetDuplex (iDuplex)
' SetColorMode (iColorMode)
End Sub
Public Function IsBounded(vArray As Variant) As Boolean

'If the variant passed to this function is an array, the function will return True;
'otherwise it will return False
On Error Resume Next
IsBounded = IsNumeric(UBound(vArray))

End Function

Public Function ListPrinters() As Variant

Dim bSuccess As Boolean
Dim iBufferRequired As Long
Dim iBufferSize As Long
Dim iBuffer() As Long
Dim iEntries As Long
Dim iIndex As Long
Dim strPrinterName As String
Dim iDummy As Long
Dim iDriverBuffer() As Long
Dim StrPrinters() As String

iBufferSize = 3072

ReDim iBuffer((iBufferSize 4) - 1) As Long

'EnumPrinters will return a value False if the buffer is not big enough
bSuccess = EnumPrinters(PRINTER_ENUM_CONNECTIONS Or _
PRINTER_ENUM_LOCAL, vbNullString, _
1, iBuffer(0), iBufferSize, iBufferRequired, iEntries)

If Not bSuccess Then
If iBufferRequired > iBufferSize Then
iBufferSize = iBufferRequired
Debug.Print "iBuffer too small. Trying again with "; _
iBufferSize & " bytes."
ReDim iBuffer(iBufferSize 4) As Long
End If
'Try again with new buffer
bSuccess = EnumPrinters(PRINTER_ENUM_CONNECTIONS Or _
PRINTER_ENUM_LOCAL, vbNullString, _
1, iBuffer(0), iBufferSize, iBufferRequired, iEntries)
End If

If Not bSuccess Then
'Enumprinters returned False
MsgBox "Error enumerating printers."
Exit Function
Else
'Enumprinters returned True, use found printers to fill the array
ReDim StrPrinters(iEntries - 1)
For iIndex = 0 To iEntries - 1
'Get the printername
strPrinterName = Space$(StrLen(iBuffer(iIndex * 4 + 2)))
iDummy = PtrToStr(strPrinterName, iBuffer(iIndex * 4 + 2))
StrPrinters(iIndex) = strPrinterName
Next iIndex
End If

ListPrinters = StrPrinters

End Function

Public Sub SetColorMode(iColorMode As Long)
SetPrinterProperty DM_COLOR, iColorMode
End Sub

Public Function GetColorMode() As Long
GetColorMode = GetPrinterProperty(DM_COLOR)
End Function

Public Sub SetDuplex(iDuplex As Long)
SetPrinterProperty DM_DUPLEX, iDuplex
End Sub

Public Function GetDuplex() As Long
GetDuplex = GetPrinterProperty(DM_DUPLEX)
End Function

Public Sub SetPrintQuality(iQuality As Long)
SetPrinterProperty DM_PRINTQUALITY, iQuality
End Sub

Public Function GetPrintQuality() As Long
GetPrintQuality = GetPrinterProperty(DM_PRINTQUALITY)
End Function
******************************************************

PowerPoint - Close All Windows - Except One?
Hi - I just wanted to check if it might be possible to achieve this with VB?

I have a CD which contains several (11) presentations - they all run from either a main menu (hyperlinked) or from a sub-menu (hyperlinked) - as the user selects different options (links) and opens files - it can get pretty crowded.

Ideally I would like to have a button for MAIN MENU which when clicked closes all windows and opens the MAIN MENU file.

Is this possible with VB?

any help much appreciated

thanks

jeff

VB6 Automating Powerpoint -close But Need A Bit Of Help Now
I found this code and had a play but what I would love it to automate 11 lines - on seperate boxes. This is because between each line an image comes up to the left (I'll work on that next).

It only lets me have two lines - help?!


Code:


Private Sub Command1_Click()
' Start PowerPoint.
Dim ppApp As PowerPoint.Application
Set ppApp = CreateObject("Powerpoint.Application")

' Make it visible.
ppApp.Visible = True

' Add a new presentation.
Dim ppPres As PowerPoint.Presentation
Set ppPres = ppApp.Presentations.Add(msoTrue)

' Add a new slide.
Dim ppSlide1 As PowerPoint.Slide
Set ppSlide1 = ppPres.Slides.Add(1, ppLayoutText)

' Add some text.
ppSlide1.Shapes(1).TextFrame.TextRange.Text = "My first slide"
ppSlide1.Shapes(2).TextFrame.TextRange.Text = "Automating Powerpoint-" & vbCr & "with VB6!"

' Add another slide, with a chart.
Dim ppSlide2 As PowerPoint.Slide
Set ppSlide2 = ppPres.Slides.Add(2, ppLayoutTextAndChart)

' Add some text.
ppSlide2.Shapes(1).TextFrame.TextRange.Text = "Slide 2's topic"
ppSlide2.Shapes(2).TextFrame.TextRange.Text = "You can create and use charts in your Powerpoint slides!"
ppSlide2.Shapes(3).TextFrame.TextRange.Text = "You can create and use charts in your Powerpoint slides!"

' Add a chart in the same location as the old one.
Dim cTop As Double
Dim cWidth As Double
Dim cHeight As Double
Dim cLeft As Double
With ppSlide2.Shapes(3)
cTop = .Top
cWidth = .Width
cHeight = .Height
cLeft = .Left
.Delete
End With
ppSlide2.Shapes.AddOLEObject cLeft, cTop, cWidth, cHeight, "MSGraph.Chart"

' Add another slide, with an organization chart.
Dim ppSlide3 As PowerPoint.Slide
Set ppSlide3 = ppPres.Slides.Add(3, ppLayoutOrgchart)

' Add some text.

ppSlide3.Shapes(1).TextFrame.TextRange.Text = "The rest is only limited by your Imagination"

' Add an Org Chart in the same location as the old one.
With ppSlide3.Shapes(2)
cTop = .Top
cWidth = .Width
cHeight = .Height
cLeft = .Left
.Delete
End With
ppSlide3.Shapes.AddOLEObject cLeft, cTop, cWidth, cHeight, "OrgPlusWOPX.4" 'OrgPlusWOPX.4
' is an object of the application Microsoft Organization Chart


' Setup slide show properties.
With ppPres.Slides.Range.SlideShowTransition
.EntryEffect = ppEffectRandom
.AdvanceOnTime = msoTrue
.AdvanceTime = 5 ' 5 seconds per slide
End With

' Prepare and run the slide show.
With ppPres.SlideShowSettings
.ShowType = ppShowTypeKiosk
.LoopUntilStopped = msoTrue

.RangeType = ppShowAll
.AdvanceMode = ppSlideShowUseSlideTimings
.Run
End With

' Sleep so user can watch the show.
Sleep (15000)

' Clean up.
ppApp.Quit

End Sub

Excel - On A Button Event, Open Another Closed File, Post Changes, Close File
Really new to VBA but coming along.

I hope that this hasn't been addressed already in this forum, I looked but didn't find it ...

The issue I can't resolve is this: I have a shared workbook with multiple sheets, essentially counting instances of answers from lists (lots of 'em) across all sheets. These are being summed in my 'summary' sheet (countif). Upon a button event (available on each sheet), I am posting from the summary to the summary2 sheet ... using the following:

Sub GetAns()
Sheets("Summary2").Select
Range("D5").Select
Selection.Offset(0, 0) = Application.Sum(Sheets("Summary").Range("D5").Value, Sheets("Summary2").Range("D5").Value)
Selection.Offset(1, 0) = Application.Sum(Sheets("Summary").Range("D6").Value, Sheets("Summary2").Range("D6").Value)
.+
.+

Long story, but I have Summary (current tally) and Summary2 (total tally)

The thought is this - this book is to be shared by 50+ users who will update it periodically yet constantly. What I would like to accomplish, essentially, would be to to have 'summary2' as an external closed book that accepts the posting from each save from the open books 'summary' sheet ... using vba (ActiveWorkbook.Save) in my GetAns sub ... basically 'on save, add this value to that value in that book' ... 'that' book will be a running tally of all users answers ...

Sorry, I hope this makes sense ... Can anyone help ?

Trying To Close Powerpoint Pps Slide Programatically
I am trying to find out how to programatically close down Powerpoint programatically ina pps file. I have tried the application.quit command but PPt does not recognise it and goes straight to the <End of Presentation> black screen. I am slightly at a loss at what to do....if anyone can give something to get me started or a lead, it would be greatly appreciative.

Code To Close File Without Saving?
I am sure there is code to do this but I can't recall it:

I have a macro that opens a text file in Excel, modies it and then closes it again, but I don't the users to see the message "Do you wish to save your changes?" I want the macro to automatically close the file without saving changes. And I also don't want the users to see the message "There is data on the clipboard, do you wish to keep it?".

Is there a way to close these messages or not even have them appear?

Thanks!

How To Close A Running Exe File Using VB Code
I am an absolute beginner in using VB. I have used the following code to try to close a running exe file. But when I run it, there is an run time error '48' saying that File not found "User". Can anybody help me and point out what is the problem??
thanks in advance

Public Declare Function FindWindow Lib "User" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Integer
Public Declare Function PostMessage Lib "User" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Integer
Private Const WM_QUIT = &H12


Dim sTitle As String
Dim iHwnd As Integer
Dim ihTask As Integer
Dim iReturn As Integer
sTitle = "title"
iHwnd = FindWindow(0&, sTitle)
iReturn = PostMessage(iHwnd, WM_QUIT, 0, 0&)

How Do I Close A Word File In Code?
I created a word file from an access report automatically, but I want it to be closed after it is made. Is there a way to close an open file using VB code? The report closes but the word file stays open...

Giving A Time Delay To Close Powerpoint
Hi, its me again, I can´t figure it out (my last post), so I'll Try something else... maybe I could give some time to the user to see the slide content, how can I make it, lets say for 20 secs.?

Any ideas could be very helpful!!!

How Can I Close/quit The Current Powerpoint Show?
I have a button on my last slide that when clicked, it'll open the next PPS (show) and I want it to close/quit the current show. What code can I use to do this? Thanks...

The Correct Way To Close An Excel File After Using?
Hi,
I'm using the below to open a existing excel file to do some work.
But I did not include a closing file command, I think will cause some problem when I try to open another new excel file, and also the selected existing file will open together with a new file "book1" too. Is there a way not to create a new excel file "book1"
I just wanna open the existing file and successfully close that file after use..
Anyone can help me?


Code:
Dim oXcel As Excel.Application
Dim oWorkBk As Excel.Workbook
Dim oWorkSht As Excel.Worksheet

Set oXcel = New Excel.Application
Set oWorkBk = oXcel.Workbooks.Add
Set oWorkSht = oWorkBk.Worksheets("Sheet1")

oXcel.Workbooks.Open ("C:Documents and SettingsadministratorDesktop170206initial-tariff.xls")
oXcel.Visible = True

Cleanup:
Set oWS = Nothing
If Not oWB Is Nothing Then oWB.Close
Set oWB = Nothing
oExcel.Quit
Set oExcel = Nothing

Excel {close File Without Saving}
I have today an VB application that transfer data from an access database to Excel into a "template" Excel file. When the user close the excel-template file he always get question Save (yes, no,). Is it possible to change some settings in the template or code something in VB so this message don't exist ?
The user shall only close it, and never save.

Hope someone can help me.

Close Excel File Without Workbook_BeforeClose?
Hello, Everyone:
I tried following code to get rid of Active Excel without prompt dialog.

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts = False
Application.Quit
End Sub
This works fine for manually close the Excel.
However, my VB progrm will use xlApp.workbooks.close. It stops my Excel in this case as well. Could I close the Excel to distinguish these two cases without Workbook_BeforeClose function?
Thanks you very much!
Charlie

Open And Close An Excel File
guys i have a simple question. i will be comparing data from two excel files.
can you guys help me on how i can open and close excel files.
(like simply opening and closing text files, however i'm using
excel files)
thank you guys in advance. i really nedd your help.
Edit by herilane: I have removed your other thread. Please do not start duplicate threads for a question.

.close Method On Excel File
After doing a .close on an excel workbook say


VB Code:
myexcelbook.close


i find that when i do a


VB Code:
? myexcelbook is nothing


i get a true which means that the myexcelbook still exists but if i do a


VB Code:
?myexcelbook.name


i get

"run-time error '462'

the remote server machine does not exists or is unavailable"

is this an inconsistency?

Close An Existant Excel File
Hi all!!!

How can I know when an Excel file is open, and how to close it?

Thanx !

How Can I Close Excel File If It Is Opened Already Using Vb
how can i close excel file if it is opened already using vb ...?

How To Use VB6 To Open/close And Excel File
i want to to know the command to open a particular excel file at a location (like normally a user will open excel program, then File - Open - "that excel file"). and also i want to close that excel file.

Detect If Excel File Is Close
Hi. Sorry for repetead posting. Is there anyway you can tell if an excel file (workbook) is closed?
Thanks
T M

Code To Reset The File-close Button In Word
on terminal server when any of our users (who all have their own normal.dot) click file - close, nothing happens (the doc doesn't close) (however the X still works). However if I go into the customize toolbar thing, and I right click the "close" and click reset, then it works. But I would have to do this 600 people. How can I write a macro to do this? (to reset the close thing under file. for everyone's normal.dot)

Arg! This Code To Write To A File Is Not Working!
Um, can anybody figure out why?

Code:
Open App.Path & "message_log.txt" For Append As #1

Do While Not EOF(1)
Input #1, tLine
Me.txtMessage.Text = "To " & txtDestination.Text & ": " & txtMessage.Text & tLine & vbCrLf
Loop

Close #1

I'd appreciate any help.

Auto Close File In Excel After Some Time
Hallo all!

I'd like to make a macro code for excel.
I'd like to automate one procedure.
After 5 minutes of inactivity on the file, I'd like to save and close this file.

Thanks for response!

Robi

Close Original Excel File- Should Be Simple
Hello all...    

I have an application that opens an excel file (template), renames it and then saves the new file in a set directory. Does anyone know how I can close the original template file and leave the renamed one open?

Thnx,

Johnny V

Working With Excel File...
Hi,

I have a problem...I want to do the difference of stock value in two columns wich they are in two different excel file. In file1.xls there are products and how many exists and the other one contain products and how many must be (minim stock). I need to find the difference between e.g. book1....6pcs and book1......3pcs.
iF YOU HAVE SOME TIME FOR MY PROBLEM, please give me an exemple.

Thanks a lot!

Working With Excel File
Hello everyone:

** I have an Excel file with 6 columns and 500 rows. This is my first time working with Excel files. Can you guide me how to open the Excel file and how to retrieve the information from it so that I can process. I am using visual basic 6.0 and Micrsoft Excel 2002.

Any advice it will be appreciate. Thanks to all in advance for your time.


Sincerely,

Daniel
Florida, USA

Why Is This File Input Code Not Working? It Just... Grrr!
I have this code:

Oh, wait... I can't really display it unless it's completely necessary, it's kinda confidential

but... how do I get the WRITE statement to go to a new line?

I want the quotes there, but I want each write statement to go to the next line. And since vbCrLf skips a line, I don't want to use that

Help please...

Save ListBox Text To File ¦ Got Code But Not Working :(
Hello again.

Here is my code:

VB Code:
For i = 0 To List1.ListCount - 1            List1.Selected(i) = True            Next            Open Text1.Text & "File" & ".log" For Append As #2            Print #2, "-----------------------------"            Print #2, "Files:"            Print #2, "-----------------------------"            Print #2,  [b]i[/b]            Print #2, "-----------------------------" & vbCrLf        Close #2

How can i put all of the Text from my ListBox into that file?

Working With The Chart Component In VB From An Excel File
Hey guys,
absolute newbie here.....

(Oh no! - everyone says!!)

Have just been handed a project to generate and save graphs as gif's/jpegs from an excel file. This is to be done in VB and As I have NO time in VB I am a bit overwhelmed you could say!

Can anyone point me to some good references on this?

I can get and display the data in VB in a datagrid(?) but what I need to know is how to translate that into a simple bar graph and then save it as an image file that can be uploaded to the clients.

If anyone can take pity on a newbie I would greatly appreciate it!

cheers

Working With The Chart Component In VB From An Excel File
Hey guys,
absolute newbie here.....

(Oh no! - everyone says!!)

Have just been handed a project to generate and save graphs as gif's/jpegs from an excel file. This is to be done in VB and As I have NO time in VB I am a bit overwhelmed you could say!

Can anyone point me to some good references on this?

I can get and display the data in VB in a datagrid(?) but what I need to know is how to translate that into a simple bar graph and then save it as an image file that can be uploaded to the clients.

If anyone can take pity on a newbie I would greatly appreciate it!

cheers

VB 5.0 Code Not Working With Manifest File Created By Prior Install
The code was recompiled with changes on the server with VB5.0. It uses a ocx ss32x25.ocx and is referenced to a MANIFEST file. The executable works on the server but is not working on my local machine where VB is not installed. Could anyone please help.

Uploading Any File Via FTP To A Ftp Server - INCLUDES WORKING SOURCE CODE
I'm just wondering is there any way to do this in VB without the extremely long API or extra modules or anything - like using components such as Winsock or Inet (I've heard it is possible, but maybe that's rubbish).

I haven't got a problem with API or extra modules. It's just that I'm going to need this for a college project which is going to be examined, and I'd rather go through the hassle (if it's worth the time) of learning how to use the control and then using it in my own project. I'd rather not use someone else's code since

1) I'm going to have to reference that in my coursework, which might make examiners go "oh, this person doesn't know real solid programming. He's just copied and pasted anything he could find off the internet. Even a baby can do that!"

2) I could just not reference that, but thats really wrong and they'd probably suspect with all the commenting like

VB Code:
'FTP Transfer via API'(c) John Smith 2005. You can freely distribute this code'Website: [url]http://www.planetsourcecode.com[/url]'Email: [email]johnsmith@someisp.com[/email]'...  


If you could come up with something, then that would be absolutely brilliant. I've tried PlanetSourceCode already and have searched the forums. By the way, I am handing reps out

kregg

File Read Code Not Working While Running As Windows Service.. Pls Help Me Out
Hi , please help. I have done a small application to read a xml file and copy the requirement contents to another text file in a fixed format. all these need to be run as a windows service during specfic intervals.
the code is working when it is executed separately with out making as service. but when i place that code in a timer function and make the application as service, the file read code is not working. please help me out ... i need to submit this assigment today.

Working With Excel &#039;97 Workbooks: Transfer && Automatically Save To A Specified File
What I have done (code is listed below):
1) rename and save file automatically (if this is the first time that I am transfering information over - it works. But if the file is already open and I make changes to original and I retransfer the items over - it crashes)

* What I am trying to do is create a new workbook and transfer information from Original worksheet to a New worksheet (This allows others to email this file - trying to make an exact copy). I want the new file to rename (Original file has the word "Backup" in it and New file changes to the word "Memo") automatically save whether it is a brand new workbook never been saved or if it is currently open and changes have been made.

I need some advice!

Current code below!

Public Sub NewWorkBook()
Dim strOriginalName As String
Dim strNewName As String

'This creates a new workbook that copies an existing worksheet with formulas
'to a new worksheet without formulas so it can be emailed out

'Takes activeworkbook file path and puts into a string
Let strOriginalName = ActiveWorkbook.FullName

'Copies all information from Original spread sheet
Range("A1:F39").Copy

'Creates a new workbook
Set newBook = Workbooks.Add

'Pastes Original contents into a new workbook
ActiveSheet.Range("a3").PasteSpecial Paste:=xlValues

'Setting up to change the file name that contains the word "Backup" to "Memo"
ActiveSheet.Range("a1") = strOriginalName

Let ActiveSheet.Range("a2") = ActiveSheet.Range("a1")
ActiveSheet.Range("a2").Replace What:="Backup", Replacement:="Memo", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

Let strNewName = ActiveSheet.Range("a2")
ActiveSheet.Rows("1").Hidden = True
ActiveSheet.Rows("2").Hidden = True

Excel 2000, Create Powerpoint Org Chart From Excel.
I want to create a powerpoint org chart from Excel using information held in Excel. I have found how to add an Org chart into Powerpoint but can't find anywhere that tells you how to change the details/options or add Subordinates Managers etc and alter those details.

Anyone have any ideas (I don't want to create seperate text boxes if possible.)

Ps if you can create a good powerpoint org chart from excel, any ideas on the best layout of information in the spreadsheet to work through and create it.

This is one of those, that would be good if you can do it (created them in the past and are time consuming pains), rather than has to be done last week ideas.

Regards.

rob.

The Close (X) Not Working..
I copied this code from somewhere who suggested in this form for the (X) button on top left of my MDIParent ( frmmain ) form.. but when I press the button.. it simply exits the program without the popup.. whats wrong with the code


Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Select Case MsgBox("Are You Sure You want to exit the Program?", vbYesNo, " Exit Application")
Case vbYes
Call closealldb
End
Case vbNo
Exit Sub
End Select
End Sub

Argh! So Close To Working..
VB Code:
Count = 1While Count < Len(mdlRandom.strTarget)    If strDashes(Count) = "" Then strDashes(Count) = "_" 'If there's nothing there, put a dash in    Count = Count + 1Wend Count2 = 1While Count2 < Len(mdlRandom.strTarget)    frmGame.lblDisplay = frmGame.lblDisplay & " " & strDashes(Count2) & " " 'Displays the array.    Count2 = Count2 + 1Wend


What this does is stores letters in an array, and where there isn't a letter, it puts a dash in that slot. Then it "prints" the whole array to a label.

As you might've guessed, it's a Hangman game. It all works, except for the fact that it copies itself over and over again when you make a guess. I know why (because I tell it to, basically):
'frmGame.lblDisplay = frmGame.lblDisplay & " " & strDashes' is the problem line because it prints whats already in the label, then adds onto the end of it. But if I don't tell it to do that I only end up with one character (because it overwrites everything in the label instead of adding to it).

So my problem is basically, how do I get it to print the new contents of the array OVER THE TOP OF the old ones? All I can get it to do is either put it next to the old ones, or overright the first character with the next one :/

That probably made no sense

I'll try an example.


Quote:





This is what I WANT to happen:

*Target word is 'apple'. Player guesses 'a'.

- Display shows: a _ _ _ _

*Player guesses 'l'

-Display shows: a _ _ l _


This is what ACTUALLY happens.

Either:

*Target word is 'apple'. Player guesses 'a'.

- Display shows: a _ _ _ _

*Player guesses 'l'

-Display shows: a _ _ _ _ _ _ _ l _

Or:

*Target word is 'apple'. Player guesses 'a'.

- Display shows: _

*Player guesses 'l'

-Display shows: _






That probably didn't help the explanation any, but meh. It's been a long day

Close Button Not Working
The close buttons (the "x" on the top right corner of the forms) are sometimes not responding. But I'm very sure that the forms are working fine, becoz I got command buttons that can close the forms. Is there any solution to this? Thanx.

VB Code For PowerPoint - Help
Hi, i am making a PowerPoint Presentation (PPT) and i need to create a kind of expandable box with different options, each one sending to a predefined slide in the presentation.

When i put this kind of expandable box in powerpoint, the vb coding windows open, and i am really noob on this and dont know what to put on there.
I know that is a simple vb code, but really dont know what to do.
Is anybody here with experience to help me solve this little problem?

Thanks in advance for the help!

Close Shell Window Not Working Help Please
guys,


how can i close the command prompt .......

say i : shell "ping 192..168.100.111"
then a command prompt appear and after a few seconds then i would like to close that command prompt .... how to?, Master


EXAMPLE :
Dim phandle1 As Long

If (Trim(txtipi1.Text) <> "") Then
phandle1 = Shell("ping -t " & txtipi1.Text, vbMinimizedNoFocus)
wapintstorage.setwapip1handle = phandle1
End If


later i issue this :

SendMessage wapintstorage.getwapip1handle, WM_CLOSE, 0&, 0&


It AINT WORKING

Formatting Word: I Am So Close To Having It All Working
Hi everyone ..... I am so close to having this test project working so that I can get the actual project done, but I am still having one slight problem.
When I run this program currently, the insertion point(cursor) in word is at the beginning of the first line ... I would really desire it to be at the end of the file.
Here is all the code that matters ...

Option Explicit

Public objWord As Word.Application
Dim FormToPrint As Word.Document
Dim strWorkingName As String
Dim Range1 As Range
Dim Range2 As Range
Const ConstantString As String = " This is a constant string"
Const ConstantString2 As String = " This is constant string 2"


Private Sub Command1_Click()

IsProgramRunningWord

Dim aWorking As Document

With objWord
.WindowState = wdWindowStateNormal
.Documents.Add
strWorkingName = .ActiveDocument.Name

Set FormToPrint = .Documents(strWorkingName)
Set Range1 = FormToPrint.Range
Range1.ParagraphFormat.Alignment = wdAlignParagraphCenter
Range1.Font.Name = "Arial"
Range1.Font.Bold = wdToggle
Range1.Font.Size = 12
Range1.InsertAfter (ConstantString)
objWord.Visible = True

Range1.Collapse wdCollapseEnd

Set Range2 = FormToPrint.Range


' 1st You have to insert a new paragraph to prevent the
'following paragraph format to apply on the previous one

Range2.InsertParagraphAfter

' 2nd Then apply the ParagraphFormat only on the new
'added Paragraph that is the last paragraph of the Range

With Range2.Paragraphs(Range2.Paragraphs.Count).Range
.ParagraphFormat.Alignment = wdAlignParagraphLeft
.Font.Name = "Times New Roman"
.Font.Size = 8
.Bold = wdToggle
.InsertAfter (Text1)
.Collapse wdCollapseEnd
.InsertAfter " "
.InsertAfter (Text2)
.InsertParagraphAfter
.InsertAfter "This is the final line"
End With
Range2.Collapse wdCollapseEnd
Range2.InsertParagraphAfter

I was hoping the last .InsertParagraphAfter would move the insertion point, but it does not

objWord.Visible = True
End With

End Sub

I cannot find the object for "Cursor" or "Insertion Point" or anything else that I would identify as what I need to manipulate and word help is not finding it either!
If someone knows the answer, i would appreciate it, in the mean time, i shall keep trying.

Thanks
Michael

Run Code When Powerpoint Opens
Power Point question:

Is it possible to run vb code on opening a particular Presentation?

I have written some macros that tailor a presentation to specific needs, at design time (adds different pictures and titles to separate slides), but I would like to distribute the presentation widely and want a custom toolbar with the macros to be created in the user's Powerpoint, when they open the presentation, if it doesnt already exist.

I can of course create the tool bar in my powerpoint, but when I distribute it to someone who hasnt used it yet and is not familiar with macros, I'd like the toolbar to be automatically created for their use.

Is this possible?

Thanks in advance

Not Close Thead When I Close Excel
I have developed, a .net dll. I call this dll from excel VBA code. In dll code I throw a thread. I need the thread still is running when I close Excel. How can I do it?
Thanks


________________
Hip Hop Videos
Foro Heavy

Copyright © 2005-08 www.BigResource.com, All rights reserved