Free Microsoft Excel 2013 Quick Reference

An error occurred initializing the VBA LIBRARIES (65535)

When I want to open the Excel (97 version, Windows 98), I receive the
following message: "An error occurred initializing the VBA libraries
(65535)".When I click "OK" the Excel however opens, but can not open all of
my excel documents.The same message I recceive when I want to open in Excel
TOOLS/MACRO/VISUAL BASIC EDITOR. What has hapened and how can I resolve this
problem? Thanks, Jovan Milojkovic, Belgrade!


Post your answer or comment

comments powered by Disqus
I want 5 members to work simultaneously on excel file. But it is possible
only one person can work .when accesing this file by others its showing the
error "an error occured initializing the vba libraries 40040".Please give the
solution ASAP..

Thanks & Regards

Sreejith K S

A friend of mine is using my spreadsheet, which contains two macros (which the wonderful people here at OzGrid helped me with!!!). The problem is she said that she is receiving the following error when she opens the spreadsheet:

An error occurred initalizing the VBA libraries (126)

She stated that she is using version Excel 9.0.2720.

Now I created the spreadsheet using Office 2003. I saw some information in regards to this problem, but it was for Excel 2000, so I figured, I better come here to be sure. Thanks so much!! Please let me know if there is any more specific information you require.

I am troubleshooting an error which you may find interesting.

Operating system: Windows NT

When opening Excel 97, the following error message pops up:
"Could not register the Visual Basic Environment. Please run setup."

The only choice is to click "ok". After clicking ok, the following message pops up:
"An error occurred initializing the VBA Libraries. (126)"

When clicking "ok" on this message, the first message pops up again. This loops through twice before opening Excel. The same error message pops up when we tried to add-in new VBA libraries. We've re-installed Excel 97 again on this machine and still the same error occurs. We've re-named the Excel template "personal.xls" and then re-opened Excel so that it would create a new blank template, this didn't work either. We thought the template may been corrupted.

Anyone see this error before or have any ideas?

An error occurred in the underlying security system. An internal error occurred.

I sent a digitally signed e-mail to a client. She responded to my e-mail with an encrypted, signed e-mail. I imported her cerificate. When I try to open this e-mail, I get the above error with no other additional support information. I have done a "repair" on the Microsoft 2007 Office Ultimate and it still returns the same error. I am able to open unsigned, unencrypted e-mails just fine AND I am able to open this by using Internet Explorer 8, going to to my e-mail server site and it opens the encrypted e-mail just fine. I am using Windows 7 Pro.
Any help would be greatly appreciated.
I will say that I am very aggravated and dissappointed with Microsoft in that this is a NEW installation of an OS AND a new installation of Office 2007 Ultimate and there are immediately issues with both and I am unable, apparently, to get any assistance from Microsoft in resolving Setup and first use problems on brand new software. Frankly, I do not have hours and days and posssibley weeks to look through endless UNHELPFUL Knowledge Base articles, etc. looking for a resolution. Microsoft should support their products better than this!!
I can type in the EXACT errors I am receiving and get nothing. When I do finally find a resolution, it usuallly has the EXACT wording of the error in the article. Why is that?
There is NEVER an obvious appropriate category to post my issue in!

Since installing Office 2007 file format compatibility pack, I seem to have
lost access to VBA libraries. For example, I get error message "An error
occurred initializing the VBA Libaries (1004)" when starting Excel. I can't
find a way to uninstall the compatibility pack, or reinstate the libraries.
The technique described in the help, using add/remove programs doesn't work,
since there is no entry for Office 2003 or for Excel. Similarly, Palm
TinySheet software generates a message "COle Exception on write to Excel ...
SCODE 800a03ec".

--
chuck

Hello, this is my first post just trying to get an answer on a problem I am having with Excel. I open an .xls document and it needs to be formatted so I do what is required and then I need to fit it to one page so I go to Page Setup and change it to Fit To: 1 page. Now I go to Save As and save the file as something else and I receive an error saying: "An error occurred while saving the file." Excel crashes and the file is not saved. I uninstalled office and then reinstalled... did the office updates and still got the same error. The error is reproducable. Anyone have any thoughts, ideas, or answers?? If you need any more information, please feel free to ask and I will reply ASAP. Thank you.

I have developed a spreadsheet for monitoring Referral Activity. The Data is inputted through a user form and stored in rows on a worksheet. I am having problems as the form has a number of dates which require the careful use of Excel cell formats, whoopee... feeling a little tired of the irratic nature of these. Anyway the problem lies in a couple of lines of code that are used to format the dates when they are read to the UserForm on initializing...

txtOnRiskDate.value = Format(DateValue(Range("DateOnRisk").Value), "dd/mm/yyyy")

when this is opened on my PC there are no problems, the same with a number of my colleagues. When it is opened on some computers however an Error occurs highlighting the 'FORMAT' word and a popup saying...

'Compile Error:

Can't find project or Library'

Is this due to missing or updated library files and if so how can I fix this...?

note: I also have a Calendar ActiveX control on the form. I am running Excel 97 so I assuming that this will work on later versions of Excel. This is not the current problem, just a sanity check. The Control is a Calendar Control 8.0

I am trying to embed Excel .xls file objects that contain VBA code in pages of a .ppt file. Using the menus insert -> object -> from file.

This works fine if I use Powerpoint 2003, but when I try to use Powerpoint 2010 I can get the object inserted but when I try to edit it, I get the following errors:

First in Excel:
Error accessing file. Network connection may have been lost.

Then in PowerPoint:
Microsoft PowerPoint can't start the application required to open this object. An error occurred and this featue is no longer functioning properly. Would you like to repair this feature now? I click "no" as I know the function is fine.

then another PowerPoint error:
There isn't enough memory available to read Worksheet.

The files are stored on same disk drive.

My troubleshooting so far:
I have set all macro security for both Excel and Powerpoint 2003 and 2010 to none.I have checked any boxes that state trust VBA objects.If I insert the .xls object using PowerPoint 2003 on another system and then re-open the ppt file using 2010, I can then edit the .xls object.If I convert the .xls file to .xlsm, then insert, it will work fine.PowerPoint 2010 can insert and edit .xls objects that do not contain VBA code.I set the references in the Powerpoint VB editor to include Excel object library, no change.I have installed 2003 on the same system as 2010 (Win 7), and it will not work then, even in the 2003 applications.I have installed 2010 on the Win XP system and it did not work there either.I tried dragging and dropping the xls file onto the ppt page, that results in 7 of the 'Error accessing file. . ' messages before it inserts the object.If I insert the object in 2010, then try to edit the object on the 2003 system, I get the same edit errors.I can create a new Excel 97-2003 worksheet object, then add a macro to it after it is inserted and it will edit fine. It only errors when inserting from file.To reproduce the problem, open/create a powerpoint file (can be ppt or pptx). Then insert any xls file that contains some VBA code. Insert the file as an Excel 97-2003 worksheet object. After the object is inserted, select to edit the worksheet object. That is when the errors will occur.

Windows 7 system details:
OS - Windows 7 64-bit
Office ver - 2010 Professional Plus
Intel core2duo cpu
4GB ram

Windows XP system details:
OS - Windows XP Pro SP3
Office ver - 3002 Standard Edition SP3
Virtual machine on Oracle VM VirtualBox

Any help is greatly appreciated.

Erick

I am trying to run this VBA Code for consolidating 30 seperate sheets into one master sheet which is the 31st sheet. An error occurs on the ActiveSheet.Paste line tin the sub macro-- Any suggestions? help would be much appreciated


	VB:
	
 ConsolLoop() 
    Sheets(31).Select 
    Cells.ClearContents 
    r = 0 
    n = 0 
     
    For i = 1 To 30 
        Sheets(i).Select 
        GoSub DoCopy 
        GoSub DoPaste 
        n = n + r 
    Next i 
     
    Exit Sub 
     
DoCopy: 
    Cells(1, 1).CurrentRegion.Select 
    Selection.Copy 
    r = Selection.Rows.Count 
    Return 
     
DoPaste: 
    Sheets(31).Select 
    Cells(1, 1).Offset(n, 0).Select 
    ActiveSheet.Paste 
    Return 
     
End Sub 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines


I have a VBA macro that runs no problem on my PC. When I run this macro on other PC's I get an error about invalid project or library and the code stops on the following areas:

the 'format' part of:

Finish = Format(Range("B8").Value, "hh:mm:ss")

or the 'htmlconvert' part of the following:

intResult = htmlconvert(chtConvert, False, False, False, 1252, strHTMFilePath)

Is this something to do with the references or even running SP1 for 97?

???????????

LJ

Hi
andy pope me a vba code for a search in my workbook this is the part were i double click on a search result in a textbox and i active the cell result

	VB:
	
 
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) 
     
    Dim strSheet As String 
    Dim strAddress As String 
     
    strSheet = ListBox1.List(ListBox1.ListIndex, 1) 
    strAddress = ListBox1.List(ListBox1.ListIndex, 2) 
    If strAddress  "" Then 
        Worksheets(strSheet).Activate 
        Range(strAddress).Activate 
    End If 
End Sub 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
i have an error with the line
Range(strAddress).Activate sometime...
eg i have the name carole enter in d6 and when i do the search for this name he find several carole( because i have carole in other sheets and those work ok) but with this search when i double clic in the search result it give me an error 1004 the range method fail...
it give me an error also when the cell i search use this function
=Module1.SheetName(G3)
where the module is the name of the sheet

	VB:
	
 SheetName(rAnyCell) 
    Application.Volatile 
    SheetName = rAnyCell.Parent.Name 
End Function 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
do you know why and what to do in those case

thanks
and i wish you all everything you ask and need for 2005
happy new years
[/QUOTE]

I want to find the last row in within the range Z22 to AB52. However an error occur if all the cells within the range are empty. I tried to add in "On Error Resume Next" but the lastrow value did not return a 0.

How can i assign lastrow value to be 0 if all the cells are empty?
Thanks for any help in advance!

Sheets("sale").Select
With Range("Z22:AB52")
On Error Resume Next
lastrow = .Find(What:="?*", After:=.Cells(1, 1), LookIn:=xlValues, _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

End With

I have a simple macro as follows:

Sub OpenNext()
OpenNext:
On Error GoTo ErrHdlr4
NewwbkName = Application.GetOpenFilename
Workbooks.Open (NewwbkName)
Exit Sub
ErrHdlr4:
NextEntry = MsgBox("Error...Also I have a long message here# is it possible to make the message box# start a new row where the number signs are?", vbRetryCancel, "No File Selected")
If NextEntry = vbRetry Then
GoTo OpenNext
End If
End Sub

The problem is that if an Error occures (by clicking Cancel in the open file bos) then it goes to the error handling the first time, but if I then click retry, then cancel to cause an error again I get a VB Error 400...

Its like it doesnt recognize the On Error GoTo the second time around.

Any Help would be appreciated

My column headings a
A = Description
B = 1st Half
C = 2nd half
D = total year

in cells B10 and C10 the user is to enter the "calendarization" %, i.e., the
% of total sales that occur in the first and second half of the year. Because
it is redundant, I have NOT aggregated the total in cell D10.

I want to display a visual warning if the % entered in B10 and C10 exceed
100%. For now, I have planted an "error" message in the unused cell D10 which
is remains as long as the total does not exceed 100% but which appears,
through Conditional Formatting, in bold red lettering if the total exceeds
100%.

Is there any other way to display such an error message, through Validation
or VBA?

Dear All,

I am using a piece of code I located on Ron de Bruins excellent site that
allows for a range in excel to be mailed within the body of an outlook
message. The code works beautifully but does not return any value for the
ComboBoxes I have within the range. Is it possible for these to be visible
as well in the e-mail message? I am including the code for reference.

Sub Mail_Selection_Outlook_Body2()
' You must add a reference to the Microsoft outlook Library
' Don't forget to copy the function RangetoHTML2 in the module.
' Is not working in Office 97
Dim source As Range
Dim dest As Workbook
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem

Set source = Nothing
On Error Resume Next
Set source = Selection.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If source Is Nothing Then
MsgBox "The selection is not a range or the sheet is protect" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If

If ActiveWindow.SelectedSheets.Count > 1 Or _
Selection.Cells.Count = 1 Or _
Selection.Areas.Count > 1 Then
MsgBox "An Error occurred :" & vbNewLine & vbNewLine & _
"You have more than one sheet selected." & vbNewLine & _
"You only selected one cell." & vbNewLine & _
"You selected more than one area." & vbNewLine & vbNewLine & _
"Please correct and try again.", vbOKOnly
Exit Sub
End If

Application.ScreenUpdating = False
source.Copy
Set dest = Workbooks.Add(xlWBATWorksheet)
With dest.Sheets(1)
.Cells(1).PasteSpecial Paste:=8
' Paste:=8 will copy the column width in Excel 2000 and higher
.Cells(1).PasteSpecial xlPasteValues, , False, False
.Cells(1).PasteSpecial xlPasteFormats, , False, False
.Cells(1).Select
Application.CutCopyMode = False
End With

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.HTMLBody = RangetoHTML2
.Send 'or use .Display
End With

dest.Close False
Set OutMail = Nothing
Set OutApp = Nothing
Set dest = Nothing
Application.ScreenUpdating = True
End Sub

Public Function RangetoHTML2()
' You can't use this function in Excel 97
Dim fso As Object
Dim ts As Object
Dim TempFile As String
TempFile = Environ$("temp") & "/" & Format(Now, "dd-mm-yy h-mm-ss") &
".htm"
With ActiveWorkbook.PublishObjects.Add( _
SourceType:=xlSourceRange, _
Filename:=TempFile, _
Sheet:=ActiveSheet.Name, _
source:=ActiveSheet.UsedRange.Address, _
HtmlType:=xlHtmlStatic)
.Publish (True)
End With
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2)
RangetoHTML2 = ts.ReadAll
ts.Close
Set ts = Nothing
Set fso = Nothing
Kill TempFile
End Function

--
Andy Tallent

We are running Microsoft Server 2003 on one of our servers and we need to
install Excel 2003 on same server. After install, when we open Excel, we get
a warning stating, 'Cannot Use Object Linking and Embedding', and then
another warning stating, 'An Error Occurred in initializing the VBA
Libraries(14)'.

Do you know how we can fix this? Is it somehow a security issue? We have
double-checked that we have downloaded the right VBA libraries.

Thanks in advance for your help.

In the recent (& extremely useful) Bullen, Bovey, Green book it is
recommended not to put error trapping in the form Initialize or
Activate events but instead to let the error be handled by the
procedure which loaded the form or displayed it. This seems to make
good sense but if an error occurs in my Activate event it does not
cascade back to the calling procedure but instead gives me an error
message. Am I missing something here?

(If the error occurs in the Initialize event then this is handled as
desired).

Thanks,
Andrew

My column headings are:
A = Description
B = 1st Half
C = 2nd half
D = total year

in cells B10 and C10 the user is to enter the "calendarization" %, i.e., the
% of total sales that occur in the first and second half of the year. Because
it is redundant, I have NOT aggregated the total in cell D10.

I want to display a visual warning if the % entered in B10 and C10 exceed
100%. For now, I have planted an "error" message in the unused cell D10 which
is remains as long as the total does not exceed 100% but which appears,
through Conditional Formatting, in bold red lettering if the total exceeds
100%.

Is there any other way to display such an error message, through Validation
or VBA?

I am Initializing the userform with code below. It works fine if I save my userform on multipage1.page(2) but when I save the userform with multipage1.page(0) I am getting an error using the code below. The ComboBox1 and DTpickers are on the page(2). Is there way to fix this error without initializing the userform on page2?

Thanks

Sub
UserForm_Initialize()
    cmbSwitches.AddItem "BB1"
    cmbSwitches.AddItem "BB2"
    cmbSwitches.AddItem "IE1"
    cmbSwitches.AddItem "IE2"
    cmbSwitches.AddItem "IR1"
    cmbSwitches.AddItem "IR2"
    cmbSwitches.AddItem "SS1"
    cmbSwitches.AddItem "SS2"
    ActiveWorkbook.Worksheets("Start").Activate
    UserForm1.MultiPage2.Value = 0
    ComboBox1.AddItem "BB1"
    ComboBox1.AddItem "BB2"
    ComboBox1.AddItem "IE1"
    ComboBox1.AddItem "IE2"
    ComboBox1.AddItem "IR1"
    ComboBox1.AddItem "IR2"
    ComboBox1.AddItem "SS1"
    ComboBox1.AddItem "SS2"
    MultiPage1.Pages(2).DTPicker1.Value = Date
    MultiPage1.Pages(2).DTPicker2.Value = Date
End Sub


Dear All,

I am using a piece of code I located on Ron de Bruins excellent site that
allows for a range in excel to be mailed within the body of an outlook
message. The code works beautifully but does not return any value for the
ComboBoxes I have within the range. Is it possible for these to be visible
as well in the e-mail message? I am including the code for reference.

Sub Mail_Selection_Outlook_Body2()
' You must add a reference to the Microsoft outlook Library
' Don't forget to copy the function RangetoHTML2 in the module.
' Is not working in Office 97
Dim source As Range
Dim dest As Workbook
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem

Set source = Nothing
On Error Resume Next
Set source = Selection.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If source Is Nothing Then
MsgBox "The selection is not a range or the sheet is protect" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If

If ActiveWindow.SelectedSheets.Count > 1 Or _
Selection.Cells.Count = 1 Or _
Selection.Areas.Count > 1 Then
MsgBox "An Error occurred :" & vbNewLine & vbNewLine & _
"You have more than one sheet selected." & vbNewLine & _
"You only selected one cell." & vbNewLine & _
"You selected more than one area." & vbNewLine & vbNewLine & _
"Please correct and try again.", vbOKOnly
Exit Sub
End If

Application.ScreenUpdating = False
source.Copy
Set dest = Workbooks.Add(xlWBATWorksheet)
With dest.Sheets(1)
.Cells(1).PasteSpecial Paste:=8
' Paste:=8 will copy the column width in Excel 2000 and higher
.Cells(1).PasteSpecial xlPasteValues, , False, False
.Cells(1).PasteSpecial xlPasteFormats, , False, False
.Cells(1).Select
Application.CutCopyMode = False
End With

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "ron@debruin.nl"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.HTMLBody = RangetoHTML2
.Send 'or use .Display
End With

dest.Close False
Set OutMail = Nothing
Set OutApp = Nothing
Set dest = Nothing
Application.ScreenUpdating = True
End Sub

Public Function RangetoHTML2()
' You can't use this function in Excel 97
Dim fso As Object
Dim ts As Object
Dim TempFile As String
TempFile = Environ$("temp") & "/" & Format(Now, "dd-mm-yy h-mm-ss") &
".htm"
With ActiveWorkbook.PublishObjects.Add( _
SourceType:=xlSourceRange, _
Filename:=TempFile, _
Sheet:=ActiveSheet.Name, _
source:=ActiveSheet.UsedRange.Address, _
HtmlType:=xlHtmlStatic)
.Publish (True)
End With
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2)
RangetoHTML2 = ts.ReadAll
ts.Close
Set ts = Nothing
Set fso = Nothing
Kill TempFile
End Function

--
Andy Tallent

Hi

I created A workbook with a few macros. After I saved the workbook, close it and ope it all the macros have gone.
when i click on a button (assigned to a macro) it says "cannot run the macro "workbook.xlsx'!Nextinvoice'. The macro may not be available in this workbook or all macros are disable."
after that another error comes up saying "an error occurred while initializing the VBA libraries (40040)"

I tried reinstalling ms office 2007 and still doesnt work
can you please help?

Hi,
After 4 month of hard labor and great support from ozgrid i am touching the end of my project.

My last 2 steps are the protection and the error handling ... Concerning protection i will simply define a password to access my VBA source code. However I am quite sure that the future users will find some bugs in my coding, and i am afraid that when those bugs will come up they will tend to open the VBA source code ... I have not done any testing yet, i am just trying to gather some information.

My question is : Is a "code error handling " exist ? i would like this macro automatically stop the execution when an error occurs in the macros procedure and display a message with my contacts so i can support the user immidiately ?

Thanks in advance

Hi all,
I have registered an automatic trading platform in which I can send Buy/Sell orders to the stock exchange. In their user manual they gave the following example for a user method that will send orders with VBA. I want to send the orders from Excel but I haven't succeed implementing it.

The method is: User.SendMaofAsynchSpeedOrder Method
Their example is:


	VB:
	
, _ 
    ByRef Orders() As MaofOrderType, _ 
    ByRef ErrNO As Long, _ 
    Optional ByVal SPCOrder As Long = 0) As Long 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
While the MaofOrderType was declared in their example as:


	VB:
	
 Type MaofOrderType 
    Branch         As String 
    Account        As String 
    Option         As String 
    Operation     As String 
    Ammount        As String 
    Price          As String 
    Sug_Pkuda      As String 
    Asmachta       As String 
    Pass           As Long 
    OrderId        As Long 
     
End Type 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
Parameters:

SessionId
Unique Session Identification number that identifies the session for which the function is called.

Orders
Array of MaofOrderType containing all details regarding the orders that are being sent.

ErrNO
If an error occurs during the operation, an error number will be relayed back to the client application.

My question is how do I implement the User.SendMaofAsynchSpeedOrder Method ?

Thanks a lot

I want to copy an embedded object and and then paste it on the last used cell. However everytime i do this an error occurs.


	VB:
	
 last_cell() 
     '
     ' last_cell Macro
     ' Macro recorded 10/6/2007 by Faisal
     '
     '
    Sheets("Analysis").Select 
    ActiveSheet.Shapes("Object 10").Select 
    Selection.Copy 
    Selection.SpecialCells(xlCellTypeLastCell).Select 
    ActiveSheet.Paste 
End Sub 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
The error occurs in this line ( Selection.SpecialCells(xlCellTypeLastCell).Select ).
Best Regards
Faisal


No luck finding an answer? You could always try Google.