vb6 installation on Win 8.1 - vb6

For several years I have been running a compiled VB6 program on an church office computer. I had the vb6 program installed on my home computer (Win 7) This program ran without problems. The program opened Excel spreadsheets and allowed the user to manipulate the data on the spreadsheet.
My Windows 7 computer crashed. I have a Windows 8.1 computer and have loaded vb6 on this computer. The installation appears to be successful except when I run the same visual basic project I get a Runtime Error '-2147319779 Automation Error Library not registered.' A sample of my code is shown below:
Dim oExcel As Excel.Application
Set oExcel = Excel.Application
oExcel.Workbooks.Open ("C:\FPCE Financial\FY-2014\2014-01 Financials.xls")
Application.Visible = True
The error occurs on the "Set oExcel = Excel.Application" line.
Any help would be appreciated.

If you haven't set a reference to Excel you need to use "Late Binding" to create the Excel object. As #Noodles says - if you don't have Office installed, it won't work period.
Try changing this
Dim oExcel As Excel.Application
Set oExcel = Excel.Application
To this
Dim oExcel As Object
Set oExcel = CreateObject("Excel.Application")

Related

Separate process is not creating in MS PowerPoint while creating in MS Word and Excel

We have designed Microsoft Addins for MS PowerPoint 2019 written in VB.net.
There I am trying to create separate process in MS PowerPoint to open a presentation/file using the given below snippet
Dim objPpt As PowerPoint.Application
Dim objDoc As PowerPoint.Presentation
objPpt = CreateObject("Powerpoint.Application")
objDoc = objPpt.Presentations.Open(processFile, False, , True)
objPpt.Visible = True
but it creates threads of Parent file and does not open a file as a separate process where in MS Word I use the given below snippet
Dim objWord As Word.Application
Dim objDoc As Word.Document
objWord = CreateObject("Word.Application")
objDoc = objWord.Documents.Open(processFile, , , True, , , , ,, , , , ,, ,)
objWord.Visible = True
And it opens the word document as a separate process.
So I need to create separate process for each file/presentation in MS PowerPoint
Can you help in resolving this issue ?
Here are some more information about on which environment I'm working :
Operating System : Microsoft Windows 10 Pro
Code Editor : Visual Studio 2019
Technology : Vb.net(.Net Framework 4.8)
MS Office Version : 2019(32 bit)
Word and Excel both allow multiple instances of themselves to be created.
PowerPoint does not (other than as the result of an obscure bug).
I would like to share the impact of trying multiple applications of PowerPoint. As per the Microsoft paragraph below it will be sharing the process so painting of Menu bar/Standard bar/Add-ins tabs must be sharing objects so you cannot perform operation independently. Performed operation will going to impact other PPT screen.
Refer Link: About PowerPoint Instance
Multiple instances of Word (Winword.exe), Excel (Excel.exe), and Microsoft Access (MSAccess.exe) can run simultaneously. Therefore, these servers are defined as Single Use (Multiple Instances) servers. Only one instance of PowerPoint (Powerpnt.exe) can run at any given time. Therefore, PowerPoint is a Multiuse (Single Instance) server.
Also refer screenshot:

ActiveX cannot create object on Set outA = CreateObject("Outlook.Application")

I have a legacy VB6 application to allow a user to send an email from the application itself.
Dim outA As Outlook.Application
Set outA = New Outlook.Application
If outA Is Nothing = True Then
'Outlook is not open... so need to create a new outlook
Set outA = CreateObject("Outlook.Application")
End If
In Windows 7 Office 2007 it works. User can have Outlook open and it works with no issues.
In Windows 10 Office 2016 this code does not work. It gives me an error on
Set outA = New Outlook.Application.
If Outlook is not open, the code works. I'm only getting this error if Outlook is open.
The error is...
ActiveX cannot create object error 429.
I have local privelages on my computer.
If I open my VB6 .exe explicitly as ADMIN and Outlook as ADMIN as well - the code gives me no issues.
I have UAC prompt disabled.
I cannot give ADMIN rights to user.
Am I missing a dll or something? I have a few more applications that have been used in Windows 7 and I have not had this issue.
Keep the early binding for development and once complete, scrap it for the late bind. Don't forget to remove the reference to Microsoft Outlook xx Object Library in VBE.
Early binding:
Dim outA As Outlook.Application
Set outA = New Outlook.Application
Late Binding:
Dim outA As Object
Set outA = CreateObject("Outlook.Application")
The reason is that early binding references a specific version of Outlook e.g. Microsoft Outlook 14.0 Object Library which is specific for Office 2010, so if it's not available it throws an error. The reference itself is marked with a "missing".
The late binding's CreateObject("Outlook.Application") takes care of that.
Repare office and ok (for me that was the solution)

Using ADOX via VBScript

Shouldn't you be able to implement the ADOX library via VBScript? The code below runs perfect via Access 2010 on Windows 7, Office 2010 32-bit, but doesn't via a VBScript. Isn't ADOX just another COM Object like say FileSystemObject?
Dim objADOX
Set objADOX = CreateObject("ADOX.Catalog")
objADOX.ActiveConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Zamdrist\Desktop\Work\Scripts\Shell.accdb"
MsgBox objADOX.Tables.Count
Sorry, I should point out, VBScript complains that the provider does not exist. Odd because I do in fact have Access 2010 installed.
This is not meant as an answer just simply as a tip that has helped me tremendously. I am constantly working with providers that only work with 32 bit so i always add the attached code to all of my scripts. This way it doesn't matter if the machine that is executing the code is 32 or 64 bit.
'Check for 64 bit and run as 32 bit if needed.
'On error resume next
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oWs = CreateObject("WScript.Shell")
windowsdir = oWs.ExpandEnvironmentStrings("%windir%")
If InStr(LCase(WScript.FullName), windowsdir & "\system32\") And oFso.FolderExists(windowsdir & "\SysWow64") Then
oWs.Run windowsdir & "\SysWow64\WScript.exe """ & WScript.ScriptFullName & """"
WScript.Quit
End If
'code to run as 32 bit

Presentations.Open requires PowerPoint 2007 to be open?

I have a macro runTest in a PowerPoint file test.pptm that I wish to call by using the following VB script. All works well when the script is called on a machine with Office 2010, but the script will only work with Office 2007 providing the PowerPoint application has been opened before calling the script. I'd be interested to hear whether anyone has experienced a similar problem, or to hear of any potential solutions.
Option Explicit
On Error Resume Next
RunProcess
Sub RunProcess()
Dim pptApp
Dim pptPresentation
Set pptApp = CreateObject("PowerPoint.Application")
Set pptPresentation = pptApp.Presentations.Open("C:\test.pptm", True)
pptApp.Run "test.pptm!runTest"
pptApp.Quit
Set pptPresentation = Nothing
Set pptApp = Nothing
End Sub
I resolved the problem by adding
pptApp.Visible = True
after creating pptApp and before opening the presentation.
In the event that it needs Powerpoint launched, I would just trigger the launch as part of the vbscript
Set WshShell = wscript.CreateObject("wscript.Shell")
WshShell.Run "C:\Program Files (x86)\Microsoft Office\Office12\POWERPNT.EXE"
You could build in some error handling to see which version is installed, and call the appropriate exe file

I would like to reference a new excel object created with shell

I have Excel 2003 and 2010 on my machine so when I use set xlapp = new excel.application it creates a new Excel 2003 application. My work around is to create a new Excel 14 application using shell. It works but I need to open an existing excel file to reference the object later.
I would like to reference the object without opening an existing file. Is there any way to reference the new Excel app without using the file name. Below is code for an existing file. Please show me the correct way to do this.
Dim MyApp As Excel.Application
TaskID = Shell("C:\Program Files\Microsoft Office\Office14\EXCEL.EXE "C:\Book2.xlsx", vbNormalFocus)
Set MyApp = GetObject("C:\Book2.xlsx").Application
You can create it ans close Excel ...
strFileName = "c:\test.xls"
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True ' You don't have to use this property....
Set objWorkbook = objExcel.Workbooks.Add()
objWorkbook.SaveAs(strFileName)
objExcel.Quit
Would that work for you? See here original solution: Create an Excel file using vbscripts

Resources