472,984 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,984 software developers and data experts.

problem with vb.net and powerpoint automation

Rut
Does anyone know how to start powerpoint from vb.net without the ppt
screen appearing. I want to keep it hidden? Using this code:

Try
pp = New PowerPoint.Application
pp.Visible = Office.MsoTriState.msoTrue
pp.WindowState =
PowerPoint.PpWindowState.ppWindowMinimized

Application.DoEvents()
Catch ex As Exception
MsgBox("Error opening powerpoint. Error is: " &
ex.ToString)
Me.Close()
Exit Sub
End Try

The main ppt screen appears momentarily and then minimizes. I've tried
setting .visible to false and get error message: Invalid operation.
Hiding application is not allowed.

Is there some way to lock the screen to prevent this initial
flickering?

Thanks,
RUt
Post a follow-up
Nov 20 '05 #1
8 6981
On 26 Apr 2004 07:39, ru*****@rjrt.com (Rut) wrote:
Does anyone know how to start powerpoint from vb.net without the ppt
screen appearing. I want to keep it hidden? Using this code: Is there some way to lock the screen to prevent this initial
flickering?

What if you pass the /S command-line switch to PowerPoint when you start
it? That's supposed to suppress the splash screen.

--
-Ben-
Ben M. Schorr, MVP-OneNote
OneNote FAQ: http://home.hawaii.rr.com/schorr/Com...OneNoteFAQ.htm
SchorrTech Blog: http://www.thespoke.net/MyBlog/bschorr/MyBlog.aspx
Nov 20 '05 #2


Since I'm using the object model, there is no way to pass command line
parameters (that I'm aware of).

Thanks,
rut

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3
Just curious... What happens if you leave out the "Visible" and
"WindowState" properties? I haven't worked with PowerPoint, but I have
automated Excel from VB.NET and never had to change any of these settings to
keep the application from appearing.

Scott
"Mike Rutledge Rutledge" <ru*****@rjrt.com> wrote in message
news:uA**************@tk2msftngp13.phx.gbl...


Since I'm using the object model, there is no way to pass command line
parameters (that I'm aware of).

Thanks,
rut

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #4


I get an error msg saying powerpoint frame window does not exist.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #5
What functions are you trying to perform using PowerPoint automation
(loading a file, saving a file, creating a presentation, etc.)? It sounds as
though you are trying to do things that require the window to be shown while
you have the window hidden or minimized. If you could show some more code it
would help.

Scott
"Mike Rutledge Rutledge" <ru*****@rjrt.com> wrote in message
news:e4*************@tk2msftngp13.phx.gbl...


I get an error msg saying powerpoint frame window does not exist.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #6


Basically, I'm opening a number of different presentations, pulling
individual slides from these presentations into a new presentation, and
finally showing the new presentation in slidesorter view. Here is all
the code:
Sub BuildPresentation()
'Dim pp As PowerPoint.Application
Dim pp As Object
Dim pres1 As PowerPoint.Presentation
Dim pres2 As PowerPoint.Presentation
Dim ppSlides As PowerPoint.Slides
Dim ppSlide As PowerPoint.Slide
Dim newSlide As PowerPoint.Slide
Dim cnt As Integer
Dim i, index, j As Integer
Dim tmp As String
Dim slide As String
Dim num1, num2
Dim oldGatefold, newGatefold As String
Try
'Create a powerpoint object
pp = CreateObject("PowerPoint.Application")
'pp.WindowState = PowerPoint.PpWindowState.ppWindowMinimized
pp.Visible = Office.MsoTriState.msoTrue
pp.WindowState = PowerPoint.PpWindowState.ppWindowMinimized

Application.DoEvents()
Catch ex As Exception
MsgBox("Error opening powerpoint. Error is: " & ex.ToString)
Me.Close()
Exit Sub
End Try

Try

'We have to open this template file so the slides we pull
out
'will have the correct templated scheme
pres2 =
pp.Presentations.Open("C:\DATA\Powerpnt\caps\_tmp. pot")

Catch ex As Exception
MsgBox("Error opening Powerpoint template. Error is: " &
ex.ToString)
Me.Close()
Exit Sub
End Try

'Keep form on top
Me.TopMost = True
Application.DoEvents()

pb1.Maximum = progCnt
lblProgress.Text = "Building Presentation. Please wait..."

' MsgBox("Starting build")

Try
'Slides can be in a number of different gatefolds (different
ppt presentations.
'We cycle through and pull out the slides for each gatefold
and add them
'to a new presentation.
For i = 1 To UBound(arrGateFolds)
tmp = arrGateFolds(i)
pb1.Value = i 'increment progress bar
' MsgBox("tmp: " & tmp)
Application.DoEvents()
If RTrim(tmp) = "" Then Exit For
'The entry will have a gatefold name, space, slide
number
'We need to separate them out
index = InStr(tmp, " ")
newGatefold = Mid(tmp, 1, index - 1)
'MsgBox("Gatefold: " & newGatefold)
slide = RTrim(Mid(tmp, index + 1, 20))
'MsgBox("slide: " & slide)

'If the gatefold name changes we need to close that
'presentation and open the new one.
If newGatefold <> oldGatefold Then
If Not IsNothing(pres1) Then pres1.Close()
pres1 = pp.Presentations.Open(newGatefold)
oldGatefold = newGatefold
End If

'try to pull out the desired slide
Try
ppSlide = pres1.Slides.Item(CInt(slide))
Catch ex As Exception
'must not exist so set slide to nothing
MsgBox("Error opening slide: " & newGatefold & " " &
slide)
ppSlide = Nothing
End Try

'copy and paste the slide to new presentation
If Not IsNothing(ppSlide) Then
pres1.Slides.Item(CInt(slide)).Copy()
pres2.Slides.Paste()
End If
Next

Catch ex As Exception
MsgBox("Error adding slides to new presentation. Error is: "
& ex.ToString)
pres1.Close()
pres2.Close()
pp.Quit()
Me.Close()
Exit Sub
End Try

'Let's delete the first slide as it is the template slide
pres2.Slides.Item(1).Delete()
pres2.SaveAs(ppFileName,
PowerPoint.PpSaveAsFileType.ppSaveAsDefault, Office.MsoTriState.msoTrue)
pp.Windows.Item(2).ViewType =
PowerPoint.PpViewType.ppViewSlideSorter
pres1.Close()
pres2.Save()
pres2.Saved = Office.MsoTriState.msoTrue

'Display that we have saved new presentation
lblProgress.Text = "Presentation saved as: " & ppFileName
Application.DoEvents()
t2.Enabled = True
While t2.Enabled = True
Application.DoEvents()
If t2.Enabled = False Then Exit While
'Just loop here a few seconds to show message.
End While

pp.WindowState = PowerPoint.PpWindowState.ppWindowMaximized
pp.Presentations.Item(1).Saved = Office.MsoTriState.msoTrue
End Sub

presentation names and a slide number is passed into the array.
Something like C:\ppt\sales.ppt 4 means pull the 4th slide out of
this presentation and paste it into the new one.

Thanks for taking the time to look at this.

Rut

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #7
I'm afraid you may be out of luck. It seems that you must set the "Visible"
property to True to be able to open a presentation. Therefore, the window
will always be shown even if it's only for a brief moment. My only other
thought was to set the location of the window so that it was off screen when
it was first shown. However, this can't be done if the window is maximized
or minimized which depends on the last state the window was in. It seems
Microsoft never thought of this scenario. The only examples I've seen all
have a call to set "Visible = True" which shows the form. What's the point
in automation if the window has to be visible? I'd be interested to see the
solution if you find one.

Sorry I couldn't be of more help...

Scott
"Mike Rutledge Rutledge" <ru*****@rjrt.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...


Basically, I'm opening a number of different presentations, pulling
individual slides from these presentations into a new presentation, and
finally showing the new presentation in slidesorter view. Here is all
the code:
Sub BuildPresentation()
'Dim pp As PowerPoint.Application
Dim pp As Object
Dim pres1 As PowerPoint.Presentation
Dim pres2 As PowerPoint.Presentation
Dim ppSlides As PowerPoint.Slides
Dim ppSlide As PowerPoint.Slide
Dim newSlide As PowerPoint.Slide
Dim cnt As Integer
Dim i, index, j As Integer
Dim tmp As String
Dim slide As String
Dim num1, num2
Dim oldGatefold, newGatefold As String
Try
'Create a powerpoint object
pp = CreateObject("PowerPoint.Application")
'pp.WindowState = PowerPoint.PpWindowState.ppWindowMinimized
pp.Visible = Office.MsoTriState.msoTrue
pp.WindowState = PowerPoint.PpWindowState.ppWindowMinimized

Application.DoEvents()
Catch ex As Exception
MsgBox("Error opening powerpoint. Error is: " & ex.ToString)
Me.Close()
Exit Sub
End Try

Try

'We have to open this template file so the slides we pull
out
'will have the correct templated scheme
pres2 =
pp.Presentations.Open("C:\DATA\Powerpnt\caps\_tmp. pot")

Catch ex As Exception
MsgBox("Error opening Powerpoint template. Error is: " &
ex.ToString)
Me.Close()
Exit Sub
End Try

'Keep form on top
Me.TopMost = True
Application.DoEvents()

pb1.Maximum = progCnt
lblProgress.Text = "Building Presentation. Please wait..."

' MsgBox("Starting build")

Try
'Slides can be in a number of different gatefolds (different
ppt presentations.
'We cycle through and pull out the slides for each gatefold
and add them
'to a new presentation.
For i = 1 To UBound(arrGateFolds)
tmp = arrGateFolds(i)
pb1.Value = i 'increment progress bar
' MsgBox("tmp: " & tmp)
Application.DoEvents()
If RTrim(tmp) = "" Then Exit For
'The entry will have a gatefold name, space, slide
number
'We need to separate them out
index = InStr(tmp, " ")
newGatefold = Mid(tmp, 1, index - 1)
'MsgBox("Gatefold: " & newGatefold)
slide = RTrim(Mid(tmp, index + 1, 20))
'MsgBox("slide: " & slide)

'If the gatefold name changes we need to close that
'presentation and open the new one.
If newGatefold <> oldGatefold Then
If Not IsNothing(pres1) Then pres1.Close()
pres1 = pp.Presentations.Open(newGatefold)
oldGatefold = newGatefold
End If

'try to pull out the desired slide
Try
ppSlide = pres1.Slides.Item(CInt(slide))
Catch ex As Exception
'must not exist so set slide to nothing
MsgBox("Error opening slide: " & newGatefold & " " &
slide)
ppSlide = Nothing
End Try

'copy and paste the slide to new presentation
If Not IsNothing(ppSlide) Then
pres1.Slides.Item(CInt(slide)).Copy()
pres2.Slides.Paste()
End If
Next

Catch ex As Exception
MsgBox("Error adding slides to new presentation. Error is: "
& ex.ToString)
pres1.Close()
pres2.Close()
pp.Quit()
Me.Close()
Exit Sub
End Try

'Let's delete the first slide as it is the template slide
pres2.Slides.Item(1).Delete()
pres2.SaveAs(ppFileName,
PowerPoint.PpSaveAsFileType.ppSaveAsDefault, Office.MsoTriState.msoTrue)
pp.Windows.Item(2).ViewType =
PowerPoint.PpViewType.ppViewSlideSorter
pres1.Close()
pres2.Save()
pres2.Saved = Office.MsoTriState.msoTrue

'Display that we have saved new presentation
lblProgress.Text = "Presentation saved as: " & ppFileName
Application.DoEvents()
t2.Enabled = True
While t2.Enabled = True
Application.DoEvents()
If t2.Enabled = False Then Exit While
'Just loop here a few seconds to show message.
End While

pp.WindowState = PowerPoint.PpWindowState.ppWindowMaximized
pp.Presentations.Item(1).Saved = Office.MsoTriState.msoTrue
End Sub

presentation names and a slide number is passed into the array.
Something like C:\ppt\sales.ppt 4 means pull the 4th slide out of
this presentation and paste it into the new one.

Thanks for taking the time to look at this.

Rut

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #8

Thanks for trying.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: careta | last post by:
Hello, I'm trying to automate PP creation from VB.net. The initial code is (as extracted from MSDN's KB209960): Public Sub Command1_Click() ' Start PowerPoint. Dim ppApp As...
0
by: asadhussain | last post by:
I am trying to automate conversion of powerpoint files to html. I have developed this as a windows service and here is the conversion code: .... PowerPoint.Application ppApp = new...
0
by: Didi I. | last post by:
Hi, I've seen several instances of this question. When working with PowerPoint automation from C# you get the following error: System.InvalidCastException: QueryInterface for interface...
0
by: Dick Peterson | last post by:
I am trying to automate a PowerPoint process from C#, using late binding because the app needs to be independent of Office versions. I found an article on this in MSKB article 302902 (...
2
by: jack | last post by:
Hello, I would like to take a PowerPoint file and make JPGs or GIFs out of each slide. How can I do this in VB.NET. Thanks for any help, Jack
0
by: waheed iqbal | last post by:
I am using PowerPoint Automation with late binding i.e i m using CreateObject("PowerPoint.Application"). But im unable to register Events Of powerpoint with LateBinding. if i try to register any...
6
by: BWPanda | last post by:
Hi everyone, I'm wanting to use VB.NET to display a powerpoint presentation, much the same way as the presenter that comes with PowerPoint (when used on multiple monitors). Basically, I want to...
4
by: HibernatingBear | last post by:
Hello, I've been driving myself nuts trying to find a solution to this. I'm still a relative newbie to C#, and would be grateful for any helpful suggestions. I'm trying to find a way to...
4
by: RockyX | last post by:
Hi, How can i export some information in powerpoint using asp.net. I want to export it in different slides. I dont want it using Interop or com objects. Please suggest me some other alternatives....
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.