Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default VB code to open other applications from templates

Hi, hopefully someone can help.

I have a user that has an excel spreadsheet that they have placed button
controls on that they hope to code to open other applications from existing
templates.

I have been able to open a word and excel fine but am having problems
opening a PowerPoint presentation from a template and an InfoPath from a
template.
-----------------------------------------------------
Code that is working for Word:

Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Word.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Word.Application")
End If
appwd.Visible = True
On Error GoTo 0
With appwd
.Documents.Add ("C:\Desktop\Fixes\Excel\template1.dot")
End With
-------------------------------------------------------------------------------------
Code that is not working for Powerpoint and Infopath

Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Powerpoint.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Powerpoint.Application")
End If
appwd.Visible = True
On Error GoTo 0
With appwd
.Presentations.Add ("C:\Desktop\Fixes\Excel\TEMPLATE.pot")
End With


End Sub

Private Sub CommandButton3_Click()
Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Infopath.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Infopath.Application")
End If
'appwd.Visible = True
On Error GoTo 0
With appwd
.XDocuments.Add ("C:\Desktop\Fixes\Excel\Template Request a Resource
OPS.xsn")

-----------------------------------------------

For powerpoint I can open the template direct is I change the
..Presentations.Add to .Presentations.Open, but the user needs to open a
instance not the template?

Thanks for you time,
Colin

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default VB code to open other applications from templates

Try

With appwd
.ActivePresentation.applytemplate
("C:\Desktop\Fixes\Excel\TEMPLATE.pot")
End With

--
Jacob (MVP - Excel)


"Colin" wrote:

Hi, hopefully someone can help.

I have a user that has an excel spreadsheet that they have placed button
controls on that they hope to code to open other applications from existing
templates.

I have been able to open a word and excel fine but am having problems
opening a PowerPoint presentation from a template and an InfoPath from a
template.
-----------------------------------------------------
Code that is working for Word:

Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Word.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Word.Application")
End If
appwd.Visible = True
On Error GoTo 0
With appwd
.Documents.Add ("C:\Desktop\Fixes\Excel\template1.dot")
End With
-------------------------------------------------------------------------------------
Code that is not working for Powerpoint and Infopath

Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Powerpoint.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Powerpoint.Application")
End If
appwd.Visible = True
On Error GoTo 0
With appwd
.Presentations.Add ("C:\Desktop\Fixes\Excel\TEMPLATE.pot")
End With


End Sub

Private Sub CommandButton3_Click()
Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Infopath.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Infopath.Application")
End If
'appwd.Visible = True
On Error GoTo 0
With appwd
.XDocuments.Add ("C:\Desktop\Fixes\Excel\Template Request a Resource
OPS.xsn")

-----------------------------------------------

For powerpoint I can open the template direct is I change the
.Presentations.Add to .Presentations.Open, but the user needs to open a
instance not the template?

Thanks for you time,
Colin

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default VB code to open other applications from templates

Thanks very much Jacob, the infopath one worked perfectly.
The Powerpoint one now gives me the following error:

"Application.ActivePresentation :Invalid request. There is no active
presentation"

Do I need to open a blank one first somehow?

Cheers,
Colin

"Jacob Skaria" wrote:

Try

With appwd
.ActivePresentation.applytemplate
("C:\Desktop\Fixes\Excel\TEMPLATE.pot")
End With

--
Jacob (MVP - Excel)


"Colin" wrote:

Hi, hopefully someone can help.

I have a user that has an excel spreadsheet that they have placed button
controls on that they hope to code to open other applications from existing
templates.

I have been able to open a word and excel fine but am having problems
opening a PowerPoint presentation from a template and an InfoPath from a
template.
-----------------------------------------------------
Code that is working for Word:

Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Word.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Word.Application")
End If
appwd.Visible = True
On Error GoTo 0
With appwd
.Documents.Add ("C:\Desktop\Fixes\Excel\template1.dot")
End With
-------------------------------------------------------------------------------------
Code that is not working for Powerpoint and Infopath

Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Powerpoint.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Powerpoint.Application")
End If
appwd.Visible = True
On Error GoTo 0
With appwd
.Presentations.Add ("C:\Desktop\Fixes\Excel\TEMPLATE.pot")
End With


End Sub

Private Sub CommandButton3_Click()
Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Infopath.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Infopath.Application")
End If
'appwd.Visible = True
On Error GoTo 0
With appwd
.XDocuments.Add ("C:\Desktop\Fixes\Excel\Template Request a Resource
OPS.xsn")

-----------------------------------------------

For powerpoint I can open the template direct is I change the
.Presentations.Add to .Presentations.Open, but the user needs to open a
instance not the template?

Thanks for you time,
Colin

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default VB code to open other applications from templates

Try the below

With appwd
.Presentations.Add WithWindow:=msoTrue
.Activepresentation.Slides.Add 1, 12
.Activepresentation.applytemplate ("C:\Optical design template.pot")
End With

--
Jacob (MVP - Excel)


"Jacob Skaria" wrote:

Try

With appwd
.ActivePresentation.applytemplate
("C:\Desktop\Fixes\Excel\TEMPLATE.pot")
End With

--
Jacob (MVP - Excel)


"Colin" wrote:

Hi, hopefully someone can help.

I have a user that has an excel spreadsheet that they have placed button
controls on that they hope to code to open other applications from existing
templates.

I have been able to open a word and excel fine but am having problems
opening a PowerPoint presentation from a template and an InfoPath from a
template.
-----------------------------------------------------
Code that is working for Word:

Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Word.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Word.Application")
End If
appwd.Visible = True
On Error GoTo 0
With appwd
.Documents.Add ("C:\Desktop\Fixes\Excel\template1.dot")
End With
-------------------------------------------------------------------------------------
Code that is not working for Powerpoint and Infopath

Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Powerpoint.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Powerpoint.Application")
End If
appwd.Visible = True
On Error GoTo 0
With appwd
.Presentations.Add ("C:\Desktop\Fixes\Excel\TEMPLATE.pot")
End With


End Sub

Private Sub CommandButton3_Click()
Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Infopath.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Infopath.Application")
End If
'appwd.Visible = True
On Error GoTo 0
With appwd
.XDocuments.Add ("C:\Desktop\Fixes\Excel\Template Request a Resource
OPS.xsn")

-----------------------------------------------

For powerpoint I can open the template direct is I change the
.Presentations.Add to .Presentations.Open, but the user needs to open a
instance not the template?

Thanks for you time,
Colin

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default VB code to open other applications from templates

All good, I appreciate your help Jacob

"Jacob Skaria" wrote:

Try the below

With appwd
.Presentations.Add WithWindow:=msoTrue
.Activepresentation.Slides.Add 1, 12
.Activepresentation.applytemplate ("C:\Optical design template.pot")
End With

--
Jacob (MVP - Excel)


"Jacob Skaria" wrote:

Try

With appwd
.ActivePresentation.applytemplate
("C:\Desktop\Fixes\Excel\TEMPLATE.pot")
End With

--
Jacob (MVP - Excel)


"Colin" wrote:

Hi, hopefully someone can help.

I have a user that has an excel spreadsheet that they have placed button
controls on that they hope to code to open other applications from existing
templates.

I have been able to open a word and excel fine but am having problems
opening a PowerPoint presentation from a template and an InfoPath from a
template.
-----------------------------------------------------
Code that is working for Word:

Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Word.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Word.Application")
End If
appwd.Visible = True
On Error GoTo 0
With appwd
.Documents.Add ("C:\Desktop\Fixes\Excel\template1.dot")
End With
-------------------------------------------------------------------------------------
Code that is not working for Powerpoint and Infopath

Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Powerpoint.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Powerpoint.Application")
End If
appwd.Visible = True
On Error GoTo 0
With appwd
.Presentations.Add ("C:\Desktop\Fixes\Excel\TEMPLATE.pot")
End With


End Sub

Private Sub CommandButton3_Click()
Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Infopath.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Infopath.Application")
End If
'appwd.Visible = True
On Error GoTo 0
With appwd
.XDocuments.Add ("C:\Desktop\Fixes\Excel\Template Request a Resource
OPS.xsn")

-----------------------------------------------

For powerpoint I can open the template direct is I change the
.Presentations.Add to .Presentations.Open, but the user needs to open a
instance not the template?

Thanks for you time,
Colin



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default VB code to open other applications from templates

You are most welcome and thanks for the feedback .

--
Jacob (MVP - Excel)


"Colin" wrote:

All good, I appreciate your help Jacob

"Jacob Skaria" wrote:

Try the below

With appwd
.Presentations.Add WithWindow:=msoTrue
.Activepresentation.Slides.Add 1, 12
.Activepresentation.applytemplate ("C:\Optical design template.pot")
End With

--
Jacob (MVP - Excel)


"Jacob Skaria" wrote:

Try

With appwd
.ActivePresentation.applytemplate
("C:\Desktop\Fixes\Excel\TEMPLATE.pot")
End With

--
Jacob (MVP - Excel)


"Colin" wrote:

Hi, hopefully someone can help.

I have a user that has an excel spreadsheet that they have placed button
controls on that they hope to code to open other applications from existing
templates.

I have been able to open a word and excel fine but am having problems
opening a PowerPoint presentation from a template and an InfoPath from a
template.
-----------------------------------------------------
Code that is working for Word:

Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Word.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Word.Application")
End If
appwd.Visible = True
On Error GoTo 0
With appwd
.Documents.Add ("C:\Desktop\Fixes\Excel\template1.dot")
End With
-------------------------------------------------------------------------------------
Code that is not working for Powerpoint and Infopath

Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Powerpoint.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Powerpoint.Application")
End If
appwd.Visible = True
On Error GoTo 0
With appwd
.Presentations.Add ("C:\Desktop\Fixes\Excel\TEMPLATE.pot")
End With


End Sub

Private Sub CommandButton3_Click()
Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Infopath.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Infopath.Application")
End If
'appwd.Visible = True
On Error GoTo 0
With appwd
.XDocuments.Add ("C:\Desktop\Fixes\Excel\Template Request a Resource
OPS.xsn")

-----------------------------------------------

For powerpoint I can open the template direct is I change the
.Presentations.Add to .Presentations.Open, but the user needs to open a
instance not the template?

Thanks for you time,
Colin

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default VB code to open other applications from templates

for Infopath try

With appwd
.XDocuments.NewFromSolution ("mentionfilename")
End With



--
Jacob (MVP - Excel)


"Colin" wrote:

Hi, hopefully someone can help.

I have a user that has an excel spreadsheet that they have placed button
controls on that they hope to code to open other applications from existing
templates.

I have been able to open a word and excel fine but am having problems
opening a PowerPoint presentation from a template and an InfoPath from a
template.
-----------------------------------------------------
Code that is working for Word:

Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Word.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Word.Application")
End If
appwd.Visible = True
On Error GoTo 0
With appwd
.Documents.Add ("C:\Desktop\Fixes\Excel\template1.dot")
End With
-------------------------------------------------------------------------------------
Code that is not working for Powerpoint and Infopath

Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Powerpoint.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Powerpoint.Application")
End If
appwd.Visible = True
On Error GoTo 0
With appwd
.Presentations.Add ("C:\Desktop\Fixes\Excel\TEMPLATE.pot")
End With


End Sub

Private Sub CommandButton3_Click()
Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Infopath.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Infopath.Application")
End If
'appwd.Visible = True
On Error GoTo 0
With appwd
.XDocuments.Add ("C:\Desktop\Fixes\Excel\Template Request a Resource
OPS.xsn")

-----------------------------------------------

For powerpoint I can open the template direct is I change the
.Presentations.Add to .Presentations.Open, but the user needs to open a
instance not the template?

Thanks for you time,
Colin

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
Macros will not run with two Excel applications open RJQMAN[_2_] Excel Programming 4 September 26th 09 01:54 AM
Open other applications using code SJW_OST[_2_] Excel Programming 2 August 6th 08 06:29 AM
Open non MS applications Frankie Excel Programming 4 August 23rd 06 12:04 AM
Users submit and charge for templates in Office Applications bull_bristol Excel Discussion (Misc queries) 1 February 6th 06 11:29 PM
Macro to open other applications Sherry Excel Programming 2 October 1st 04 10:50 PM


All times are GMT +1. The time now is 07:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"