Excel 2010 :: User-Defined Type Not Defined Compile Error When Creating PowerPoint Using VBA
Jul 29, 2014
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
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.
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
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've made a macro that inserts an entire new row above a specified cell, then updates each column of that row using offset.value and various constants and inputbox variables. Works great so far, unless I try to apply a validation rule to one of the cells.
The code I'm using to add the validation works okay when referring to a specific cell by reference e.g:
However, when I change it thusly:
With Sheet2.Range("LastRow").Offset(-1, 5).Validation .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _ xlBetween, Formula1:="=Departments" .IgnoreBlank = True .InCellDropdown = True End With
It doesn't like that one bit.
This is part of a private Sub attached to a button in the same sheet. I've had a scan through the archives looking for validation threads, but couldn't find anything that refers to problems with offsets (if indeed that is the problem here).
Have two worksheets in same workbook. First worksheet is "ReArrangedAddr" Which basically has a command button to click to run a "Sub" behind the second worksheet "Orig SH Register". When I click on button on first worksheet, I get error "Compile Error: Sub or Function not defined"
New to VBA and just trying to make some edits to some existing code. I have basically copied a pre-existing form and module and changed names from "Appendix" to "Drawing" as I am trying to replicate what the piece of code already produces for a table of appendices, for my drawings.
However, when I try and run the form I get Compile error: Variable not defined with lstDrawings highlighted.
Is this something that should be defined in my global module which I am missing?
The following code has been used previously to enter data from a userform to a worksheet without a problem. However, since I added some new bits of code I am getting a compile error with the message variable not defined.
Here is part of what I have so far and the bit that is highlighted after the error comes up is the 'Set ws' line;
Code: Private Sub CommandButton1_Click() Worksheets("Duties").Range("C5") = txtdate Worksheets("Duties").Range("H5") = txtarea Worksheets("Duties").Range("N5") = txttea Set ws = Worksheets("Duties") 'find first empty row in database iRow = ws.Cells(Rows.Count, 1) _ .End(xlUp).Offset(1, 0).Row
The code I have recently added:
Code: Private Sub UserForm_Initialize() Set wsRes = Worksheets("Resources") With wsRes .Range("B1", .Range("B" & Rows.Count).End(xlUp)).AdvancedFilter xlFilterCopy, , .Range("L1"), True With .Range("L2", .Range("L" & Rows.Count).End(xlUp)) cboTeam.List = .Value .EntireColumn.Clear
I have a two set of Macros in a workbook. One is to create a command button on a sheet and other macro will run onece the created commond button is clicked.
Macro runs fine. Command button gets created, but when I click the command button to run another macro it gives error "Compile Error: Sub or Function not defined" highlighting the code "Call Add" at the code entered for sheet. This code is added by macro in the sheet1. I am attaching a sample file as well as codes.
Sub CreateButton() Dim Obj As Object Dim Code As String Sheets("Sheet1").Select 'create button Set Obj = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", _ Link:=False, DisplayAsIcon:=False, Left:=600, Top:=30, Width:=100, Height:=35) Obj.Name = "InsertInvoiceButton" 'buttonn text
I've used Excel for many years, but finally am learning VBA, using Excel Progamming for Dummies by John Walkenbach. Excel is version 2000.
I've searched extensively on Google and on the MrExcel site for the solution to my problem, but still haven't found it . Any direction would be most appreciated.
I'm trying to execute the examples in the book, and have gotten the error message "Compile error: Variable not defined" with "MyString =" highlighted with several of the examples. Could someone please tell me where I'm going astray?
Following is the latest subroutine I typed into the module, from page 124:
Sub GetLength() MyString = "Hello World" StringLength = Len(MyString) MsgBox StringLength End Sub
It works as a regular Module but when I put it into a "Private Sub" for a button its not working.
Basically I have a master sheet that I create Tests from. I push a button and it creates a Test for others to take. I want the macro to transfer from the Master to these so when they are done I can press a button and upload the answers to a tracking sheet.
It errors on the strSecondFile
Private Sub CommandButton1_Click() Dim wbk As Workbook Dim NAME As String
'strFirstFile = ActiveWorkbook strSecondFile = Application.GetOpenFilename Set wbk = ActiveWorkbook 'Workbooks.Open(strFirstFile) NAME = Range("A6").Value
I have tracked down an overflow Error 6 to the following line:
dMax = Int(s * DPoints / SPoints)
Where all variables are defined as Integers. The error goes away when I define s as Long, but I don't understand why this should be required since none of the individual variables ever exceed the scope of an Integer (-32768 to 32767).
Strangely, I get the same overflow problem when I type either of the following calculations in the immediate window:
Note that no variables are defined, so why the overflow problem? Surely Excel/VBA should be able to work with this very basic calculation without any problem, by assigning the appropriate dimension, no?
Is this a known problem with Excel/VBA?
I am using Windows 7, with Excel 2010 (updated from 2009).
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 use MATCH to identify the Column number that contains "DL_Error", then I'll use this Column # to select a cell (found Column # & "34"), but I get the error shown in the title of this post.
Here's my current Sub Macro15() ' Macro recorded 6/18/2009 by me Range(Match("DL_ERROR", "A31:CW31", 0) & "34").Select 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.
I am trying to put two subs into a macro. They work individually, but when I put them together, I get a "Compile Error: Variable Not Defined" Message. I was told I have to define the variable in the sub multipleif(), but I am not certain as to how to do this. The error message highlights the line I have bolded below.
VB: Option Explicit Private Sub CommandButton1_Click() Dim mth As Variant, txt As Variant, des As Variant, wdt As Variant, I, Cell