473,721 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Appl ication
pp.Visible = Office.MsoTriSt ate.msoTrue
pp.WindowState =
PowerPoint.PpWi ndowState.ppWin dowMinimized

Application.DoE vents()
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 7074
On 26 Apr 2004 07:39, ru*****@rjrt.co m (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
"WindowStat e" 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.c om> wrote in message
news:uA******** ******@tk2msftn gp13.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.c om> wrote in message
news:e4******** *****@tk2msftng p13.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 BuildPresentati on()
'Dim pp As PowerPoint.Appl ication
Dim pp As Object
Dim pres1 As PowerPoint.Pres entation
Dim pres2 As PowerPoint.Pres entation
Dim ppSlides As PowerPoint.Slid es
Dim ppSlide As PowerPoint.Slid e
Dim newSlide As PowerPoint.Slid e
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("P owerPoint.Appli cation")
'pp.WindowState = PowerPoint.PpWi ndowState.ppWin dowMinimized
pp.Visible = Office.MsoTriSt ate.msoTrue
pp.WindowState = PowerPoint.PpWi ndowState.ppWin dowMinimized

Application.DoE vents()
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.Presentation s.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.DoE vents()

pb1.Maximum = progCnt
lblProgress.Tex t = "Building Presentation. Please wait..."

' MsgBox("Startin g 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(arrGateF olds)
tmp = arrGateFolds(i)
pb1.Value = i 'increment progress bar
' MsgBox("tmp: " & tmp)
Application.DoE vents()
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("Gatefo ld: " & 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.Presentation s.Open(newGatef old)
oldGatefold = newGatefold
End If

'try to pull out the desired slide
Try
ppSlide = pres1.Slides.It em(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(ppSli de) Then
pres1.Slides.It em(CInt(slide)) .Copy()
pres2.Slides.Pa ste()
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.It em(1).Delete()
pres2.SaveAs(pp FileName,
PowerPoint.PpSa veAsFileType.pp SaveAsDefault, Office.MsoTriSt ate.msoTrue)
pp.Windows.Item (2).ViewType =
PowerPoint.PpVi ewType.ppViewSl ideSorter
pres1.Close()
pres2.Save()
pres2.Saved = Office.MsoTriSt ate.msoTrue

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

pp.WindowState = PowerPoint.PpWi ndowState.ppWin dowMaximized
pp.Presentation s.Item(1).Saved = Office.MsoTriSt ate.msoTrue
End Sub

presentation names and a slide number is passed into the array.
Something like C:\ppt\sales.pp t 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.c om> wrote in message
news:%2******** *******@TK2MSFT NGP11.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 BuildPresentati on()
'Dim pp As PowerPoint.Appl ication
Dim pp As Object
Dim pres1 As PowerPoint.Pres entation
Dim pres2 As PowerPoint.Pres entation
Dim ppSlides As PowerPoint.Slid es
Dim ppSlide As PowerPoint.Slid e
Dim newSlide As PowerPoint.Slid e
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("P owerPoint.Appli cation")
'pp.WindowState = PowerPoint.PpWi ndowState.ppWin dowMinimized
pp.Visible = Office.MsoTriSt ate.msoTrue
pp.WindowState = PowerPoint.PpWi ndowState.ppWin dowMinimized

Application.DoE vents()
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.Presentation s.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.DoE vents()

pb1.Maximum = progCnt
lblProgress.Tex t = "Building Presentation. Please wait..."

' MsgBox("Startin g 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(arrGateF olds)
tmp = arrGateFolds(i)
pb1.Value = i 'increment progress bar
' MsgBox("tmp: " & tmp)
Application.DoE vents()
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("Gatefo ld: " & 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.Presentation s.Open(newGatef old)
oldGatefold = newGatefold
End If

'try to pull out the desired slide
Try
ppSlide = pres1.Slides.It em(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(ppSli de) Then
pres1.Slides.It em(CInt(slide)) .Copy()
pres2.Slides.Pa ste()
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.It em(1).Delete()
pres2.SaveAs(pp FileName,
PowerPoint.PpSa veAsFileType.pp SaveAsDefault, Office.MsoTriSt ate.msoTrue)
pp.Windows.Item (2).ViewType =
PowerPoint.PpVi ewType.ppViewSl ideSorter
pres1.Close()
pres2.Save()
pres2.Saved = Office.MsoTriSt ate.msoTrue

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

pp.WindowState = PowerPoint.PpWi ndowState.ppWin dowMaximized
pp.Presentation s.Item(1).Saved = Office.MsoTriSt ate.msoTrue
End Sub

presentation names and a slide number is passed into the array.
Something like C:\ppt\sales.pp t 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
1638
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 PowerPoint.Application ppApp = CreateObject("Powerpoint.Application") ' Make it visible.
0
1029
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 PowerPoint.Application(); PowerPoint.Presentation prsPres = ppApp.Presentations.Open(targetFile, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse,
0
1219
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 PowerPoint._Application failed. at PowerPoint.ApplicationClass.get_Presentations() ... This problem is not solved after re-installing office 2000. The
0
1423
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 ( http://support.microsoft.com/default.aspx?scid=kb;EN-US;302902 ) which gives a good example for work. I understand the InvokeMember techniques used here. But I don't know how to apply this to PowerPoint since I don't know how to navigate within the...
2
4395
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
1373
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 eventhandler with object i get compile time error. Is there any way to use Events of powerpoint in late binding case.
6
6319
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 show the presentation in one form/window, and in the other, have controls for moving through the presentation, list of slides, etc. I don't really want code as such, more like a tutorial on how to do something like this.
4
3263
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 create a gridview from a Web application to an automated powerpoint slide. If that is not possible, then reading the gridview items to a table created in powerpoint, all in C#. Have searched Google many times, results ranged from "can't be
4
3947
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. Rgards, RockyX
0
8840
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9131
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9064
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8007
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6669
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3189
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.