Trying to convert an Excel 2003 macro to work in Excel 2007.
The problem line is
Dim MyDataObject As DataObject
I suspect the problem is a Missing Reference, but I cannot figure out which one. I have the same ones (in 2007) as 2003 except for one which is not showing
Microsoft Forms 2.0 Object Library
Is this the one it needs? It is called something else in 2007?
The ones I do have ticked are
Visual Basic For Applications Microsoft Excel 12.0 Object Library OLE Automation Microsoft Office 12.0 Object Library Microsoft ADO Ext. 2.8 for DDL and Security Microsoft DAO 3.6 Object Library Microsoft ActiveX Data Objects 2.8 Library Microsoft Scripting Runtime Microsoft XML v2.6
I am using Microsoft Excel 2010 and Microsoft VBA 7.0 on my system. I would like to eventually create a PowerPoint and insert charts generated in the Excel workbook. In the meantime, I cannot get the basic PowerPoint created.
The line in red is highlighted blue when the compile error "User-defined type not defined" message box appears.
Public Sub TryAgain() Dim myPowerPoint As PowerPoint.Application ' ' do nothing for now 'End Sub
I have set the references such that Microsoft Project 14.0 Object Library is indeed checked. The Excel file only contains this code in a module. All sheets are blank. Nothing else is written yet.
This code works fine when I use it, but not when a co-worker uses it on his PC. The code and VBA references are the same. He gets the "User-Defined Type not defined" error. I'm wondering if there is an Outlook setting that may blow this up.
the code was working on his PC and then it stopped though no changes were made to the code. That's why I think it may be blocked by an Outlook setting.
Set appOutLook = CreateObject("Outlook.Application") Set MailOutLook = appOutLook.CreateItem(olMailItem) MailOutLook.Subject = "E-mail"
I am having difficulty getting a form to work the way that I would like it to work. I have a form that is used to display questions that my students will be answering. The form also is used to put the answers into a worksheet. I have 2 sheets. Sheet2 has the questions, student answers, and correct answers. Sheet1 is used to indicate correct answers and to keep track of percentage correct. I am fairly new to VB. I have 2 pieces of code that I am going to post. The first one works and the second one doesn't.
This is in the "This Workbook" section and it works. Option Explicit Public intNoQ As Integer Public strNoQ As String Public NumberofQuestions As Integer Dim StudentName As String Dim InputBoxAnswer As String Public Sub Workbook_Open() Application.Visible = False 'Hide Excel Load Questions Load NumberCorrect NumberofQuestions = Worksheets("Sheet1").Range("K3").Value For intNoQ = 1 To NumberofQuestions strNoQ = VBA.CStr(intNoQ) If intNoQ = 1 Then Questions.Controls("QuestionNumberBox").Value = "Question#" & strNoQ Questions.Controls("QuestionBox").Value = Worksheets("Sheet2").Range("B1").Value End If Questions.Controls("CorrectBox" & strNoQ).Visible = True Questions.Controls("CorrectLabel" & strNoQ).Visible = True Next intNoQ...............
the first time font.bold is set to true, it completes w/o error. The bolded line returns 'application defined or object defined error 1004'. Ive tried activating the new sheet immediately before setting bold (like the first time it gets set) but it still errors.
I have problems with setting Validation input title and message. When in column "C" I type product code, data validation of corresponding cell in column "D" changes to list of diameters allowed for that product. That works fine. But i also want to set validation message to show allowed diameters.I set it in VBA using named ranges. But for every second line (13, 15, etc on attached file) I get an application-defined or object-defined error. The rest (14, 16 etc) works ok.
I have a very strange problem in DEBUG mode, because i get this error "Application-defined or object-defined error" when referring to a cell and assigning it a value so it goes to my error handler and i have a Resume Next there. It continues to go through the code whilst continuing to go to the error handler but when i step out of the function it restarts again from the beginning on the called function and then on the second run of my code it seems to WORK!?! So i'm thinking what the hell is going on, it falls over and fails the first time round and works the second time round? In free-run mode from excel i just get a #VALUE!
I am having some trouble with a variable range selection within a regression. I keep getting an "application-defined or object-defined error." I've isolated each statement to find that the code that is causing the regression not to work is below (the error for that line of code states that the Select method of Range class failed):
I'm trying to enter a series of formulas into a worksheet using vba. However, this code is giving me Run time error '1004', along with the description in the title. This is the first formula (they're all relatively similar).
I am currently working in an application in which I use the following user defined types:
Public Type correlationstruct corr As Variant corrstd As Variant lower As Variant upper As Variant support As Variant End Type
I have a public variable called myctafund, of type ctafund:
Public myctafund As ctafund
My problem is the following: When I need to update myctafund, I first want to clean it entirely before putting new values, so as to be sure older values do not stick around (I do not necessarily overwrite all the values of the mycta type).I can't figure out a way of clearing the entire myctafund variable in one shot. I tried:
but I am granted by a nasty excel error. I'd like to avoid writing 200 lines of code just to clean the entire variable.
I'm trying to figure out why I can run a bit of code on my machine but on another machine I get an: Application-defined or object-defined error. The code is in an excel file on a network drive and it pulls up a form, once the form is submitted it runs some code that looks like so
When opening a blank excel workbook I receive the error "1004 Application-defined or object-defined error". I press OK. And the message appears 2 more times before I am able to work in Excel. Doesn't matter what excel file I am opening, does the same thing. I do not know how to lookup programming code for any macros I am running. I would like to get rid of this error! It is a nusance.
I get "Application-defined or Object-defined error" , run-time error 1004.
Option Explicit Sub Initialize() Dim rList As String Dim CountRows, CurrCol As Integer rList = "myTemplate" Range("A2").Select CountRows = Range(Selection, Selection.End(xlDown)).Rows.Count
CurrCol = 7 With Range("G : G" & CountRows + 1) With .Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _ xlBetween, Formula1:="=" & rList .ErrorTitle = "JC Message" .InputMessage = "Select requested template" .ErrorMessage = "You must enter a template from a list only" .IgnoreBlank = False End With End With End Sub
I have an array with structure, i.e. User Defined Type. Assume the user defined type has two elements: Element1 and Element2 and array name is Array.
So the definition is:
Dim Array(1 To 10) As UserType
and access to elements is
The problem is that I need to pass the whole set of Element1 or Element2 to a function. Should it have been two separate arrays, it would not be a problem. But because of the user defined structure I have no idea how to pass a single element.
I hope there is another solution rather than to use loops. I have many arrays like this with complex structures. I simply can not replicate all of them.