|
Sheets("Orders").Range("A2:G200").Select
I have this code in a macro in a module on one workbook. I know the sheet is there, and the code will actually run every now and again but most of the time when i go to run the macro it gives me a 1004 runtime error, Select Method of Range Class Failed, I can't understand why this code will run only sometimes, its like there is a bug in the excel. Its simple straight forward code but it just won't go.
Karma
|
|
|
|
|
One problem could be that you have not defined the workbook where the sheet Orders is. So if the topmost workbook is not containing such sheet, it will fail.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
please explain why the following code snipped cannot work:i am trying to assign a sql data/records to a textbox for my GUI
Dim dr As Dataset.cashierRow
me.textbox1.text()=dr.cashierId.toString ??????
|
|
|
|
|
You received numerous answers yesterday to this topic. Don't spam the board with the same question.
You can find the answer(s) here.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
Because your dr object doesn't have a property or method called "cashierId".
|
|
|
|
|
Hello,
Im trying to follow this tutorial on this site:
http://www.codeproject.com/KB/vb/CustomAppAutoUpdate.aspx?fid=431225&fr=1#xx0xx[^]
I have added the code to my project and i get as far as the autoupdate.exe program opening up and then nothing happens for a few seconds and then i get this error:
Microsoft .NET Framework
Unhandled exception has occured in your application.
Object reference not set to an instance of an object.
Can anyone shed any light on why this may be?
|
|
|
|
|
I've never used his code, and don't plan on it any time soon.
You're going to have to ask him why the code bombed. Basically, that error means that you tried to execute a method or property on an object that didn't exist. Essentially, you did this:
Dim myTB As TextBox = Nothing
myTB.Text = "This will throw the Object reference not set to an instance of an object."
|
|
|
|
|
You might be best off asking the author of the article in the forum at the bottom of the article. They may reply to you.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
yeh thanks ive emailed him so hopefully he will come back to me :S
this doesnt help suggest where about the error is does it?
in killappexe() for example?
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at WindowsApplication1.updateModule.KillAppExe()
at WindowsApplication1.autoUpdate.Timer1_Tick(Object sender, EventArgs e)
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
|
|
|
|
|
Hi i am new here and also new to vba(just started to learn a few days ago).
i have and excel spreadsheet name generating new exchnage rate.xls.
I am trying to figure out how to extra certain cells ( example : b4 to b50 and e4 to e50) and also adding in the title into each respective cells ( example : under b4 to b50 the title will be currency )and save it into a new excel sheet.
I already got the new excel sheet up.The thing i am stuck with is the cells and title part.Any help would be greatly appreciate.My codes are as below.Thanks =D.
my codes
Option Explicit
Public Sub Revaluation()
Dim NewName As String
Dim nm As Name
Dim ws As Worksheet
Dim fname As Variant
If MsgBox("Copy specific sheets to a new workbook" & vbCr & _
"New sheets will be pasted as values, named ranges removed" _
, vbYesNo, "NewCopy") = vbNo Then Exit Sub
With Application
.ScreenUpdating = False
' Copy specific sheets
' *SET THE SHEET NAMES TO COPY BELOW*
' Array("Sheet Name", "Another sheet name", "And Another"))
' Sheet names go inside quotes, seperated by commas
On Error GoTo ErrCatcher
Sheets(Array("Exchange rate")).Copy
On Error GoTo 0
' Paste sheets as values
' Remove External Links, Hperlinks and hard-code formulas
' Make sure A1 is selected on all sheets
For Each ws In ActiveWorkbook.Worksheets
ws.Cells.Copy
ws.[A1].PasteSpecial Paste:=xlValues
ws.Cells.Hyperlinks.Delete
Application.CutCopyMode = False
Cells(1, 1).Select
ws.Activate
Next ws
Cells(1, 1).Select
' Remove named ranges
For Each nm In ActiveWorkbook.Names
nm.Delete
Next nm
' Input box to name new file
'NewName = InputBox("Please Specify the name of your new workbook", "New Copy")
' Save it with the NewName and in the same directory as original
ActiveWorkbook.SaveCopyAs ThisWorkbook.Path & "\" & NewName & "Revaluation.xls"
'ThisWorkbook.Path & "\" & NewName & ".xls"
ActiveWorkbook.Close SaveChanges:=False
.ScreenUpdating = True
End With
Exit Sub
ErrCatcher:
MsgBox "Specified sheets do not exist within this workbook"
End Sub
|
|
|
|
|
Hello All
I am Using Vb.net 3.5 in my windows application
I have a String.
Dim Name as string
Name="F1 Help"
I want to show 'F1' as Underline and 'Help' as Bold. through my vb.net code.
I am using Strings.Format mathod , But this mehod unable to convert a text into Bold or Underline
I am doing "Strings.Format("F1", "{0}")
Please, tell me what is the correct format of this function.
Arindam Banerjee
Sr. Software Developer
Rance Computer Pvt Ltd.
Kolkata (India)
|
|
|
|
|
You can't do this using String.Format. How the fonts a rendered depend on the control that will show the text. Since you want both parts of that phrase rendered differently, you'd have to render them seperately.
You have a couple of choices. The first is creating a custom control that renders the text yourself. The second is creating a usercontrol that has a couple of label controls in it, each label showing one part of the text, and using different font properties to achieve what you want.
|
|
|
|
|
No Control I am using
Just Format the some parts od the String and show it in to the grid.
Arindam Banerjee
Sr. Software Developer
Rance Computer Pvt Ltd.
Kolkata (India)
|
|
|
|
|
I'll say it again. You cannot do what you want using String.Format, or any other string manipulation techniques. This will ONLY happen when the text is rendered by some kind of control. For most controls, you cannot mix font styles, so this would prohibit you from using a single control to do this. The only control in the ToolBox that can render different fonts at the same time is the RichTextBox, but that control is a bit too heavy for your requirement.
|
|
|
|
|
You want to show F1 throughout your app, but where exactly are you planning to display this? What is the intended control that this should be displayed on? Depending on the control, you may or may not have this ability already.
If not, you'll be best off doing a custom control like Dave recommended.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
No Control I am using
Just Format the some parts od the String and show it in to the grid
Arindam Banerjee
Sr. Software Developer
Rance Computer Pvt Ltd.
Kolkata (India)
|
|
|
|
|
String.Format does NOT format the text like a word processor does, the font weight, underline etc is controlled by the screen control you put the string in. String.Format is really just an easy way of building a string.
For example
Dim str1 as string = string.format("My name is {0}","Bob")
Dim str2 as string = "My name is " & "Bob"
both give the same result.
I think you have misunderstood the use of the string.format function, hopefully this will aid your understanding.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Dim str1 as string = string.format("My name is {0}","Bob")
Dim str2 as string = "My name is " & "Bob"
According to your Example how can I make the "Bob" bold
Arindam Banerjee
Sr. Software Developer
Rance Computer Pvt Ltd.
Kolkata (India)
|
|
|
|
|
You can't with string.format. All string.format does is replace the {#} part with the text after the comma. Try it a couple of times in the immediate window.
The color, size, bold, underline parts of the text are controlled by the font property of whatever control that you're trying to use. If the particular control is unable to display F1 without the underline, then you must extend an existing control or create one for your needs.
All we have gathered thus far is that its a grid of some kind. It may prove somewhat beneficial to try and post the code your attempting to work with so we have an idea of what you're trying to do.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
modified on Friday, October 24, 2008 9:28 AM
|
|
|
|
|
Why do you have it stuck in your head that you can do this with String.Format or any other string manipulation technique?? IT'S NOT POSSIBLE! If you won't listen to the answers you're getting, why should we help you??
|
|
|
|
|
Sorry, I give up. You have been told so many times now, STRING.FORMAT WILL NOT MAKE YOUR FOLD BOLD, BIG, RED OR ANYTHING ELSE DISPLAY WISE
pdnet wrote: Sr. Software Developer
sure?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Ashfield wrote: pdnet wrote:
Sr. Software Developer
sure?
FTW!
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
Yes !
I am Doing that
Sory to say, you are a FOOL,DULL and a USELESS,HELPLESS SOFTWARE SUPPORT MAN
You never doing a project by Yourself
Try using...........
Graphics.DrawString("Bob", New Font("Arial", 30, FontStyle.Bold), brush.ControlDark, 29, 10)
Arindam Banerjee
Sr. Software Developer
Rance Computer Pvt Ltd.
Kolkata (India)
|
|
|
|
|
Sorry to say that isn't the answer to your original question. All you did was reiterate, with a very specific line of code, what's we've been telling you all along. ANd that is that you can only do what you want when rendering the string.
|
|
|
|
|
Well, I'm glad I bothered to come back and check on a couple of the older forum messages. You are personal ban list of users to help anymore.
pdnet wrote:
Try using...........
Graphics.DrawString("Bob", New Font("Arial", 30, FontStyle.Bold), brush.ControlDark, 29, 10)
You still don't comprehend what string.format does and is in no way shape or fashion related to Graphics.DrawString.
Also, using a method such as drawstring to render the graphics was suggested to you in the very first response by Dave; but you didn't bother to put 2 minutes of research into it, else you wouldn't be wasting time trying to write insults to those who tried to help you.
Cheers.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|