|
Dear Experts
I want to customize the fonts used in Outllok like the font used in Text Boxes of
To field,Cc Field,Subject Field and the overall headers...i dont know how to do it..but ive created a form but its not being used by default.Any suggestions
Mahesh Sundararaman
|
|
|
|
|
I am trying to put a combo box onto an excel spreadsheet. The idea is so this bit of the code picks up.Select Case ComboBox1.Value
Case 0 '
ActiveSheet.Cells(1, 1).Value = "refund"
Case 1 '
ActiveSheet.Cells(1, 1).Value = "redec"
Case 2 '
ActiveSheet.Cells(1, 1).Value = "incentive"
But I can't put the code for the combo box onto the workbook open part wqithout an error. If it remains on theindividual sheet on the ComboBox1_Click() sub it does't update. Also my combo box code:
ComboBox1.AddItem "Refund" 'ListIndex = 0
ComboBox1.AddItem "Redecoration Allowance" 'ListIndex = 1
ComboBox1.AddItem "Tenant Incentive" 'ListIndex = 2
'Use drop-down list
ComboBox1.Style = fmStyleDropDownList
for some reason makesmultipple entries on the drop down box instead if jyust the three. Can anyone help please?
|
|
|
|
|
I think you need to look at the ComboBox1.ListIndex, to retunr the index no, starting a 0, if you've used AddItem, without specifying an index.
Hope that helps.
Giles
|
|
|
|
|
Any idea how I might do that?
Thanks for your help.
|
|
|
|
|
'Create a combo box on the worksheet called ComboBox1 and copy and paste this....
'Make sure that youtr not in d3esign mode when you use it as nothing happens
Private Sub Worksheet_Activate()
'Initialisation Code
With ComboBox1
.Clear
.AddItem "Dog" 'Index 0
.AddItem "Cat" 'Index 1
.AddItem "Mouse" 'Index 2
End With
End Sub
Private Sub ComboBox1_Change()
Dim i As Integer
i = ComboBox1.ListIndex
Select Case i
Case 0
Cells(1, 1).Value = "This is a Dog"
Case 1
Cells(1, 1).Value = "This is a Cat"
Case 2
Cells(1, 1).Value = "This is a Mouse"
End Select
End Sub
Giles
|
|
|
|
|
The With ComboBox1 .Clear bit is what I was missing and why mine were adding entries until infinity.
Many thanks.
|
|
|
|
|
Yep, becuase every time to Activate the workbook they are added. There is and Initialize event for a Workbook, but thats the only one to support the once only event. You could initialse it from there when the workbook opens.
Giles
|
|
|
|
|
How can I check if the user has pressed a specified button then change it to something else.
|
|
|
|
|
When someone pushes a button, an event has occured. So, if they click on a button named command1, you could put code in the "OnClick" event that will update the text of your text box like:
Private Sub Command1_Click()
Text1.Text = "You clicked the button."
End Sub
|
|
|
|
|
When someone pushes a button, an event has occured. So, if they click on a button named command1, you could put code in the "OnClick" event that will update the text of your text box like:
Private Sub Command1_Click()
Text1.Text = "You clicked the button."
End Sub
|
|
|
|
|
I found what I thought to be an easy way to shove a graphical VB form to a printer.
It works fine when I call ShowPrinter and change the print quality and click OK.... But I don't know how to pick up the Cancel button click of the CommonDialog1.ShowPrinter and avoid printing.
Here's the code:
CommonDialog1.ShowPrinter
Form1.PrintForm
(need to detect cancel w/in CommonDialog1.ShowPrinter - branch around Form1.PrintForm if Cancel is pressed)
Any ideas?
Thanks in advance,
\\Jim
CommonDialog1.ShowPrinter
jamesdturner@hotmail.com
|
|
|
|
|
Try this:
On Error GoTo ErrHandler
CommonDialog1.CancelError = True
CommonDialog1.ShowPrinter
Form1.PrintForm
Exit Sub
ErrHandler:
End Sub
If you have existing Error Handling code the ErrHandler would look a little different:
ErrHandler:
If Err.Number <> 32755 Then '32755 is the Error Number for Cancel being selected
'Process Error as usual
End If
End Sub
Andy Gaskell, MCSD
|
|
|
|
|
hi all,
i want to write a small macro... that can generate a csv from the excel file... well not the whole of worksheet but just the selected cells.
for example... something like this...
1, 2, 3
1, 5
4, 8, 9, 5
1
2
3,4
6, 7, 9, 10
1, 2
so if u ppl can guide me for writing this macro in VBA for Office.
tks in adv.
regards
sajid;
|
|
|
|
|
First all, I am a C++ programmer working with some VB code that I am not the best with, is there a way to create a stand alone VB .exe that will take command line parameters?
i.e. like the old Dos stuff "dir /s /d" <- I want to create an executable called dir and pass it the parameters "/s" "/d"
|
|
|
|
|
Taken from MSDN:
Function GetCommandLine(Optional MaxArgs)
'Declare variables.
Dim C, CmdLine, CmdLnLen, InArg, I, NumArgs
'See if MaxArgs was provided.
If IsMissing(MaxArgs) Then MaxArgs = 10
'Make array of the correct size.
ReDim ArgArray(MaxArgs)
NumArgs = 0: InArg = False
'Get command line arguments.
CmdLine = Command()
CmdLnLen = Len(CmdLine)
'Go thru command line one character
'at a time.
For I = 1 To CmdLnLen
C = Mid(CmdLine, I, 1)
'Test for space or tab.
If (C <> " " And C <> vbTab) Then
'Neither space nor tab.
'Test if already in argument.
If Not InArg Then
'New argument begins.
'Test for too many arguments.
If NumArgs = MaxArgs Then Exit For
NumArgs = NumArgs + 1
InArg = True
End If
'Concatenate character to current argument.
ArgArray(NumArgs) = ArgArray(NumArgs) & C
Else
'Found a space or tab.
'Set InArg flag to False.
InArg = False
End If
Next I
'Resize array just enough to hold arguments.
ReDim Preserve ArgArray(NumArgs)
'Return Array in Function name.
GetCommandLine = ArgArray()
End Function
If you need help changing this code around to fit your needs, just reply. Basically everything in the command line gets passed in by the Command Function.
|
|
|
|
|
I created a database in Access 2000. I tried to use the following code in VB 6.0 to open that database:
---
Dim wspDefault As Workspace
Dim DB As Database, DBSet As Recordset
' Grab the default workspace.
Set wspDefault = DBEngine.Workspaces(0)
' Open the database.
Set DB = wspDefault.OpenDatabase("c:\temp\xxx.mdb")
---
When I run it, though, it gives me error 3343: "Unrecognized database format".
Is this because VB does not have / know the correct Jet DLLs to access a database created in Access 2000? They must exist otherwise how is Access doing it... If this is the problem, how / where do I get the right files, and where do I put them? If not, what have I done wrong?
|
|
|
|
|
I'm guessing that you're using DAO, and I don't know too much about DAO. Make sure you have the latest version of DAO referenced in your project. Get the latest version of MDAC and Jet 4.0 SP3 here: http://www.microsoft.com/data/download.htm
Otherwise, if you're willing to use ADO, I can come up with some code for you. Get the latest MDAC either way tho
|
|
|
|
|
You need the sp5
Qapla
|
|
|
|
|
how can i include all the referenced object when i deploy my access project... I create a mde file from the database and it seems that there are missing stuff.
what tools can i use to deploy that utility... can i deploy it...
Help...
|
|
|
|
|
If you have the Office Developer Edition with MS Access you can use their Setup WIzard wich creates disk images for you as well as bringing together all (not 100%) the referenced stuff. This is the easiest way but not always problem free. If you used API functions in your code this setup program will not recognise them and you must somehow ensure that the API source files get on to the computer you are deploying to. Benefit of the Developer addition is that you get a runtime version of MS Access which adds greater security and behaves more like a standalone exe application (but there are enough querks to let you now it's not an exe). Also there are heaps of bugs relating to system folers being used as the location of your runtime application for some reason C:\My Documents\myMDE.mde /Runtime can stuff up so don't deploy in this folder.
The Hard Way
Use the object browser to view the libraries you have referenced also use the reference/cotrol lists and record all the dll, ocx, and every other file you referenced as well as it's path. Once you have done that collect all of them and write a program (or do it manually) that copies them to their original folders (dangerous do not overwrite newer versions).
Sux ha. The reason it's hard to deploy is that no one actually expected VB programmers to achieve anything, you know, we are seen as the "Wanna be programmers." and as such the part of getting your app distributed hits those software manufactures as big news .....bigger than a newspaper front page article ...."Whore becomes Christian" or "Christian WOman Becomes WHore", either way it wasn't ment to be.
|
|
|
|
|
Hi,
I am trying to retrieve the CaretPosition within a textbox. I have tried the following code within the KeyPress event of the TextBox:
Dim ptCaret As POINTAPI
Dim lPoint As Long
Dim lIndex As Long
GetCaretPos ptCaret
lPoint = (ptCaret.y * 65536) + (ptCaret.x And &HFFFF&)
lIndex = SendMessage(txtPrice.hwnd, EM_CHARFROMPOS, 0, lPoint)
If lIndex And &H8000& then
nCharIndex = lIndex Or &HFFFF0000
else
nCharIndex = lIndex And &HFFFF&
End If
GetCaretPos returns the correct x,y coordinates, but SendMessage always returns -1.
Any ideas????
Chris Mancini
|
|
|
|
|
This is a rich edit, right? Normal text boxes require a different use of the lParam parameter.
Check your lPoint value in hex and make sure it looks OK, in case the attempt to form lPoint went wrong - if it did, try using "&h10000&" instead of "65536", and try using "Or" instead of "+".
|
|
|
|
|
Thanks for your response.
Actually it is a Normal TextBox. I looked over the documentation on MSDN and found that there was a slight problem. I was passing lPoint as ClientCoordinates not ScreenCoordinates, so I fixed that, yet SendMessage is still returning -1.
MSDN Says....
"Edit controls: The low-order word contains the horizontal coordinate. The high-order word contains the vertical coordinate."
It appears that is what I am doing.....
GetCaretPos ptCaret
ClientToScreen txtPrice.hwnd, ptCaret
lPoint = (ptCaret.y * &H10000) Or (ptCaret.x And &HFFFF&)
lIndex = SendMessage(txtPrice.hwnd, EM_CHARFROMPOS, 0, lPoint)
If lIndex And &H8000& Then
nCharIndex = lIndex Or &HFFFF0000
Else
nCharIndex = lIndex And &HFFFF&
End If
Thanks
Chris Mancini
|
|
|
|
|
Ignore my rich edit comment... for some reason I thought you were passing lParam incorrectly, but you are not - my mistake.
I see no reason why this would not work then. You checked lPoint in hex to make sure it was formed right, did you? Other than that the only other reason I can think of that it would return this (it's actually returning two short integers, both -1: for line number and char number) is if there was no text in the control at the specified point... are you clicking within a portion you KNOW contains text, or are you cliking beyond the text it contains?
|
|
|
|
|
Yes I did check the lPoint value in Hex. It was set up correctly.
I am not clicking in the control to trigger the code I am doing the code within KeyPress. I know the textbox has text. And I have tried it when the cursor is at the end of the text as well as in the middle of the text.
I am stumped.
Chris Mancini
|
|
|
|