Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Excel Waiting for Another Application to Complete an OLE Action

I have some VBA code, shown below, that runs in Excel and invokes
Word and PDFCreator. It is an adaptation of the Word VBA code found
at http://www.excelguru.ca/node/95 adapted for single Word files.

When I run the first Sub listed below, I get the error " Microsoft
Excel is waiting for another application to complete an OLE action."
I went to the Windows Task Manager. Both PDFCreator and Word
(winword.exe) were still running. I killed each of them, but Excel
was still inoperable. I had to kill Excel to stop it, as Ctrl-Break
did not work.

I did search for the error on Google. I founds lots of hits,
but none of them were enlightening to me.

I am using Excel 2007 on Windows Vista.

Any suggestions on what the problem might be, or where to start?

Thanks, Alan

Sub TESTPrintWordToPDF()
PrintWordToPDFCreator ("C:\Users\Alan\Desktop\Link Test.doc")
End Sub

Sub PrintWordToPDFCreator(WordDocPath As String)
Dim pdfjob As PDFCreator.clsPDFCreator
Dim sPDFName As String, sPDFPath As String
Dim pos As Integer, sWordName As String
Dim sPrinter As String
Dim bRestart As Boolean
Dim bBkgrndPrnt As Boolean
Dim WordApp As Word.Application
Dim WordDoc As Word.Document

' Set file and path name
sWordName = FileName(WordDocPath)
pos = InStr(1, sWordName, ".doc")
If (pos = 0) Then
DisplayErrorMessage (sWordName & " is not a Word document")
Exit Sub
Else
sPDFName = Replace(sWordName, ".doc", ".pdf")
sPDFPath = FolderName(WordDocPath)
End If

If Not CheckFileExist(WordDocPath) Then
MsgBox "The file " & WordDocPath & " does not exist"
Exit Sub
End If
'
' Check that the file is not already open ***********
'
Set WordApp = New Word.Application
Set WordDoc = WordApp.Documents.Open(WordDocPath)

'Activate error handling, capture properties and set req'd
settings
On Error GoTo EarlyExit
With WordApp
sPrinter = CStr(.ActivePrinter)
.ActivePrinter = "PDFCreator"
bBkgrndPrnt = .Options.PrintBackground
.Options.PrintBackground = False
.ScreenUpdating = False
End With

'Check if PDFCreator is already running and attempt to kill the
process if so
Do
bRestart = False
Set pdfjob = New PDFCreator.clsPDFCreator
If pdfjob.cStart("/NoProcessingAtStartup") = False Then
'PDF Creator is already running. Kill the existing
process
Shell "taskkill /f /im PDFCreator.exe", vbHide
DoEvents
Set pdfjob = Nothing
bRestart = True
End If
Loop Until bRestart = False

'Assign settings for PDF job
With pdfjob
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cClearCache
End With

'Print document to PDF
WordDoc.PrintOut copies:=1

'Wait until the print job has entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop

pdfjob.cPrinterStop = False

'Wait until the file shows up before closing PDF Creator
Do
DoEvents
Loop Until Dir(sPDFPath & sPDFName) = sPDFName
' Close Word document
WordDoc.Close

Cleanup:
'Release objects and terminate PDFCreator
pdfjob.cClose
Set pdfjob = Nothing
Shell "taskkill /f /im PDFCreator.exe", vbHide
On Error GoTo 0
'Reset all application settings to user's original settings
With WordApp
.ScreenUpdating = True
.ActivePrinter = sPrinter
.Options.PrintBackground = bBkgrndPrnt
End With
WordApp.Quit
Set WordApp = Nothing
Set WordDoc = Nothing
Exit Sub

EarlyExit:
'Inform user of error, and go to cleanup section
MsgBox "There was an error encountered. PDFCreator has" & vbCrLf
& _
"has been terminated. Please try again.", _
vbCritical + vbOKOnly, "Error"
Resume Cleanup
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Excel Waiting for Another Application to Complete an OLE Action

Cells(1,1) = CheckBox1.Value & "," & CheckBox2.Value & "," & CheckBox3.Value

If this post helps click Yes
---------------
Jacob Skaria


"Alan" wrote:

I have some VBA code, shown below, that runs in Excel and invokes
Word and PDFCreator. It is an adaptation of the Word VBA code found
at http://www.excelguru.ca/node/95 adapted for single Word files.

When I run the first Sub listed below, I get the error " Microsoft
Excel is waiting for another application to complete an OLE action."
I went to the Windows Task Manager. Both PDFCreator and Word
(winword.exe) were still running. I killed each of them, but Excel
was still inoperable. I had to kill Excel to stop it, as Ctrl-Break
did not work.

I did search for the error on Google. I founds lots of hits,
but none of them were enlightening to me.

I am using Excel 2007 on Windows Vista.

Any suggestions on what the problem might be, or where to start?

Thanks, Alan

Sub TESTPrintWordToPDF()
PrintWordToPDFCreator ("C:\Users\Alan\Desktop\Link Test.doc")
End Sub

Sub PrintWordToPDFCreator(WordDocPath As String)
Dim pdfjob As PDFCreator.clsPDFCreator
Dim sPDFName As String, sPDFPath As String
Dim pos As Integer, sWordName As String
Dim sPrinter As String
Dim bRestart As Boolean
Dim bBkgrndPrnt As Boolean
Dim WordApp As Word.Application
Dim WordDoc As Word.Document

' Set file and path name
sWordName = FileName(WordDocPath)
pos = InStr(1, sWordName, ".doc")
If (pos = 0) Then
DisplayErrorMessage (sWordName & " is not a Word document")
Exit Sub
Else
sPDFName = Replace(sWordName, ".doc", ".pdf")
sPDFPath = FolderName(WordDocPath)
End If

If Not CheckFileExist(WordDocPath) Then
MsgBox "The file " & WordDocPath & " does not exist"
Exit Sub
End If
'
' Check that the file is not already open ***********
'
Set WordApp = New Word.Application
Set WordDoc = WordApp.Documents.Open(WordDocPath)

'Activate error handling, capture properties and set req'd
settings
On Error GoTo EarlyExit
With WordApp
sPrinter = CStr(.ActivePrinter)
.ActivePrinter = "PDFCreator"
bBkgrndPrnt = .Options.PrintBackground
.Options.PrintBackground = False
.ScreenUpdating = False
End With

'Check if PDFCreator is already running and attempt to kill the
process if so
Do
bRestart = False
Set pdfjob = New PDFCreator.clsPDFCreator
If pdfjob.cStart("/NoProcessingAtStartup") = False Then
'PDF Creator is already running. Kill the existing
process
Shell "taskkill /f /im PDFCreator.exe", vbHide
DoEvents
Set pdfjob = Nothing
bRestart = True
End If
Loop Until bRestart = False

'Assign settings for PDF job
With pdfjob
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cClearCache
End With

'Print document to PDF
WordDoc.PrintOut copies:=1

'Wait until the print job has entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop

pdfjob.cPrinterStop = False

'Wait until the file shows up before closing PDF Creator
Do
DoEvents
Loop Until Dir(sPDFPath & sPDFName) = sPDFName
' Close Word document
WordDoc.Close

Cleanup:
'Release objects and terminate PDFCreator
pdfjob.cClose
Set pdfjob = Nothing
Shell "taskkill /f /im PDFCreator.exe", vbHide
On Error GoTo 0
'Reset all application settings to user's original settings
With WordApp
.ScreenUpdating = True
.ActivePrinter = sPrinter
.Options.PrintBackground = bBkgrndPrnt
End With
WordApp.Quit
Set WordApp = Nothing
Set WordDoc = Nothing
Exit Sub

EarlyExit:
'Inform user of error, and go to cleanup section
MsgBox "There was an error encountered. PDFCreator has" & vbCrLf
& _
"has been terminated. Please try again.", _
vbCritical + vbOKOnly, "Error"
Resume Cleanup
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Excel Waiting for Another Application to Complete an OLE Actio

Sorry Alan, I have wrongly posted this here..


"Jacob Skaria" wrote:

Cells(1,1) = CheckBox1.Value & "," & CheckBox2.Value & "," & CheckBox3.Value

If this post helps click Yes
---------------
Jacob Skaria


"Alan" wrote:

I have some VBA code, shown below, that runs in Excel and invokes
Word and PDFCreator. It is an adaptation of the Word VBA code found
at http://www.excelguru.ca/node/95 adapted for single Word files.

When I run the first Sub listed below, I get the error " Microsoft
Excel is waiting for another application to complete an OLE action."
I went to the Windows Task Manager. Both PDFCreator and Word
(winword.exe) were still running. I killed each of them, but Excel
was still inoperable. I had to kill Excel to stop it, as Ctrl-Break
did not work.

I did search for the error on Google. I founds lots of hits,
but none of them were enlightening to me.

I am using Excel 2007 on Windows Vista.

Any suggestions on what the problem might be, or where to start?

Thanks, Alan

Sub TESTPrintWordToPDF()
PrintWordToPDFCreator ("C:\Users\Alan\Desktop\Link Test.doc")
End Sub

Sub PrintWordToPDFCreator(WordDocPath As String)
Dim pdfjob As PDFCreator.clsPDFCreator
Dim sPDFName As String, sPDFPath As String
Dim pos As Integer, sWordName As String
Dim sPrinter As String
Dim bRestart As Boolean
Dim bBkgrndPrnt As Boolean
Dim WordApp As Word.Application
Dim WordDoc As Word.Document

' Set file and path name
sWordName = FileName(WordDocPath)
pos = InStr(1, sWordName, ".doc")
If (pos = 0) Then
DisplayErrorMessage (sWordName & " is not a Word document")
Exit Sub
Else
sPDFName = Replace(sWordName, ".doc", ".pdf")
sPDFPath = FolderName(WordDocPath)
End If

If Not CheckFileExist(WordDocPath) Then
MsgBox "The file " & WordDocPath & " does not exist"
Exit Sub
End If
'
' Check that the file is not already open ***********
'
Set WordApp = New Word.Application
Set WordDoc = WordApp.Documents.Open(WordDocPath)

'Activate error handling, capture properties and set req'd
settings
On Error GoTo EarlyExit
With WordApp
sPrinter = CStr(.ActivePrinter)
.ActivePrinter = "PDFCreator"
bBkgrndPrnt = .Options.PrintBackground
.Options.PrintBackground = False
.ScreenUpdating = False
End With

'Check if PDFCreator is already running and attempt to kill the
process if so
Do
bRestart = False
Set pdfjob = New PDFCreator.clsPDFCreator
If pdfjob.cStart("/NoProcessingAtStartup") = False Then
'PDF Creator is already running. Kill the existing
process
Shell "taskkill /f /im PDFCreator.exe", vbHide
DoEvents
Set pdfjob = Nothing
bRestart = True
End If
Loop Until bRestart = False

'Assign settings for PDF job
With pdfjob
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cClearCache
End With

'Print document to PDF
WordDoc.PrintOut copies:=1

'Wait until the print job has entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop

pdfjob.cPrinterStop = False

'Wait until the file shows up before closing PDF Creator
Do
DoEvents
Loop Until Dir(sPDFPath & sPDFName) = sPDFName
' Close Word document
WordDoc.Close

Cleanup:
'Release objects and terminate PDFCreator
pdfjob.cClose
Set pdfjob = Nothing
Shell "taskkill /f /im PDFCreator.exe", vbHide
On Error GoTo 0
'Reset all application settings to user's original settings
With WordApp
.ScreenUpdating = True
.ActivePrinter = sPrinter
.Options.PrintBackground = bBkgrndPrnt
End With
WordApp.Quit
Set WordApp = Nothing
Set WordDoc = Nothing
Exit Sub

EarlyExit:
'Inform user of error, and go to cleanup section
MsgBox "There was an error encountered. PDFCreator has" & vbCrLf
& _
"has been terminated. Please try again.", _
vbCritical + vbOKOnly, "Error"
Resume Cleanup
End Sub

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
waiting for another application to complete an OLE action. Marc W Excel Programming 1 August 20th 07 07:16 PM
Microsoft Excel is waiting for another application to complete an OLE action Glen Davis Jr. Excel Discussion (Misc queries) 0 May 4th 05 04:10 PM
Microsoft Office Excel is waiting for another application to complete an OLE action Mircea Pleteriu Excel Programming 7 March 11th 05 07:53 PM
Error msg "Microsoft Excel is waiting for another application to complete an OLE action" JimPNicholls Excel Programming 0 January 16th 04 12:41 PM


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

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

About Us

"It's about Microsoft Excel"