I am trying to update some code that I didn't originally write.
I'm getting an error right out of the gate with ProgressBar, but I can't seem to identify what the problem is.
My code is:
Public Function CharStyles() As Dictionary
Dim CharacterProgress As ProgressBar
Set CharacterProgress = New ProgressBar
' some more code after this...
End Function
Hovering over 'New ProgressBar' - I see the error "ProgressBar =Object variable or With variable not set", but I can seem to find any information on using ProgessBar in VBA to get any understanding of what that error means.
Can anyone help me understand what the issue is here? Presumably this code worked before, so I'm not sure what I'm missing that's causing it to break.
Thank you.
Related
I couldn't find a solution for this on SO or other source. I apologize in advance if this is a tired question:
I have a macro that iterates through placeholders in shapes. Some of these placeholders have text, some don't. I'm trying to figure out if
.Shapes.Placeholder.TextFrame.TextRange has any value or not (In the 'watches' section of the VBA editor, this property has <The specified value is out of range.>). If it does, do something. Otherwise, continue the For Each statement. However, everything I tried has thrown out of bounds errors or something of that type.
I have tried:
If Not (placeholder.TextFrame.TextRange.Length = 0) Then: Immediately throws out of bounds error
Try/catch, which doesn't seem to exist in VBA (Gives me Sub or Function not registered)
If Not CStr(placeholder.TextFrame.TextRange) = "0" then
I'm quite out of my depth as I don't have experience with any Visual Basic iteration. I just need to, if that property is empty or null, skip over the placeholder.
EDIT: Following suggestions, I tried this:
For Each placeholder In sld.NotesPage.Shapes.Placeholders
If Not (placeholder.TextFrame Is Nothing) Then
If Not (placeholder.TextFrame.TextRange Is Nothing) Then
If Not (placeholder.TextFrame.TextRange.LanguageID Is Nothing) Then
placeholder.TextFrame.TextRange.LanguageID = lng
End If
End If
End If
Next
I still get an out of bounds error on placeholder.TextFrame.TextRange Is Nothing. Did I make a syntax error?
FINAL EDIT: Turns out there was an answer in SO after all. For this specific problem, it was enough to add On Error Resume Next right after theFor Each.
My code in vba for access was working fine, I had procedures that I wrote for different events that all worked. Then when I went to give my combo boxes and text boxes an assigned row source and now nothing works. I get this invalid outside procedure error. So after hours of trouble shooting I ended up deleting the entire form and then rebuilding it and I still get the same error. So now I just working with one event just until I can get things figured out.
Public Sub cb_op1_AfterUpdate()
tb_LbrRate1.Value = DLookup("LaborRate", "tbloperationsType", "[operationsID] = cb_op1.value")
End Sub
This use to work but now it won't?? tb_LbrRate1.value is a text box and cb_op1.value is a combo box.
I have tried this too
Public Sub cb_op1_AfterUpdate()
End Sub
I left everything blank and I still get the error when I change a value in my combo box?? I just don't get it!!!! any help would be appreciated.
Can you do this:
and check what you get?
This error in MS Access is usually because of code flying not between Sub and End Sub.
As a first step in creating a VBA script to resize a currently selected image to 100% x 100%, I'm trying to reproduce the example in http://msdn.microsoft.com/en-us/library/ee814736(v=office.14).aspx. The macro is very simple:
Sub Test()
MsgBox ("Hello world")
End Sub
The VBA script was simply created in "Project1" which opens by default when one presses Alt+F11. However, I keep getting the error "Sub or Function not defined" when trying to run the VBA script (Figures 1 and 2).
How can I make the VBA script 'accessible' to Outlook?
Figure 1 Running the "Test" macro in Microsoft Outlook
Figure 2 "Sub or Function not defined" error, with module tree in the background
I solved the problem by following the instructions on msdn.microsoft.com more closely. There, it is stated that one must create the new macro by selecting Developer -> Macros, typing a new macro name, and clicking "Create". Creating the macro in this way, I was able to run it (see message box below).
I had a similar situation with this issue. In this case it would have looked like this
Sub Test()
MsqBox ("Hello world")
End Sub
The problem was, that I had a lot more code there and couldn't recognize, that there was a misspelling in "MsqBox" (q instead of g) and therefore I had an error, it was really misleading, but since you can get on this error like that, maybe someone else will notice that it was cause by a misspelling like this...
This error “Sub or Function not defined”, will come every time when there is some compile error in script, so please check syntax again of your script.
I guess that is why when you used msqbox instead of msgbox it throws the error.
This probably does not answer your question, but I had the same question and it answered mine.
I changed Private Function to Public Function and it worked.
I need to add that, if the Module name and the sub name is the same you have such issue.
Consider change the Module name to mod_Test instead of "Test" which is the same as the sub.
I think you need to update your libraries so that your VBA code works, your using ms outlook
I'm working on a little project to make a 'memeplayer' in Excel with YouTube videos - here's a screenshot of the spreadsheet
The code I'm attempting to use is below:
Option Explicit
Sub PlaySamsMemes()
Dim sChosenTitle As String
Dim rngVideoData As Range
Dim lFinalRow As Long
Dim sLookupValue As String
lFinalRow = Range("C65536").End(xlUp).Row
sChosenTitle = Range("F4").Value
Set rngVideoData = Range("B2:C" & lFinalRow)
sLookupValue = Application.VLookup(sChosenTitle, rngVideoData, 2, False)
Memeplayer.SetVariable("Movie", sLookupValue)
End Sub
I'd be really grateful if you could tell me how to get the script to play nice with the embedded Shockwave Flash that I've named 'Memeplayer' in the Excel interface. The line I'm using to try and make it run is:
Memeplayer.SetVariable("Movie", sLookupValue)
but it just returns an 'Object required' error (Runtime Error 424). I've not worked with shapes and objects much as yet and I've no idea how to fix it. Help me please!
I've since solved the problem. I just hadn't Set the Object correctly - couldn't figure out the heirachy for it. The code is below:
Set MemePlayer = Sheets(1).MemePlayer
MemePlayer.Movie = sLookupValue
VBA has many limitations and trying to do something like this in Excel is probably not the best way to go about it. However, here are 2 websites that might shed some light on your problem:
http://chandoo.org/wp/2011/01/11/embed-youtube-videos-excel/ - this should help most I think
http://www.cpearson.com/excel/DownloadFile.aspx (from the website: http://www.pcreview.co.uk/forums/do-use-vba-play-sound-clip-website-t3893819.html)
Hope this helps.
I am trying to figure out why all of the sudden i get an error when trying to run my program. The following code below is where the error is:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> Partial Class frmPM
The error i get is highlighted on the frmPM:
An error occurred creating the form. See Exception.InnerException for details.
The error is: Object variable or With block variable not set.
I've made sure there was a End Class at the end of all that but that doesn't seem to be the problem.
What else could cause this as it worked just fine for one run then not on down the road?
Thanks!
David
Ah, it seems as though it was creating a bad object at run time in a sub it was calling when it first started. Though its odd that it would have that type of error but after i commented that out, it seemed to work just fine. :o)