Tuesday, June 28, 2005

To open file from common dialogue control in VB

Code to open file from common dialogue control in VB

Dim PlaceToSave As String
Dim strTemp As String
CommonDialog1.DialogTitle = "Open Task flow model..."
CommonDialog1.Filter = "Excel File (*.xls)*.xls"
CommonDialog1.ShowOpen
g_txt_taskflowmodel.Text = CommonDialog1.FileName


Comments Pls
Credits : Shreejith G

To Print form the MSflexgrid in VB

Code to print form the flexgrid in VB

Dim d As Single

Printer.ScaleMode = vbTwips
d = CSng(Printer.ScaleWidth) / CSng(Me.MSFlexGrid1.Width)
Printer.Zoom = CInt(d * 100)
Printer.PaperSize = vbPRPSA3
'Printer.Orientation = vbPRORLandscape

Printer.PaintPicture MSFlexGrid1.Picture, 0, 0
Printer.EndDoc


Comments pls
Credits: Shreejith G

To add Hyperlink in VB6.0

Check out the code to get hyperlink features in Visual Basic

'To make this hyperlink look really professional
'Place the lblURL into a frame
'Re-size the frame so that it is exactly the SAME size
'as lblURL. Then in design time, change the mouse pointer
'for the form to 3 I-Beam. And change the MousePointer
'for the frame to 1 Arrow.
'As stated on the previous article if linking to e-mail
'then uncomment line containing mail and comment
'line below


Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Form_Load()
With lblurl
.ForeColor = vbBlue
.Font.Underline = True
End With

End Sub

Private Sub lblurl_Click()
With lblurl
' Call ShellExecute(0&, vbNullString, "Mailto:" & .Caption, vbNullString, vbNullString, vbNormalFocus)
Call ShellExecute(0&, vbNullString, .Caption, vbNullString, vbNullString, vbNormalFocus)
End With
End Sub


Comments Pls
Credits: Shreejith G

Email with VB

Code to add email features in VB

Dim objOutlook As Object
Dim objOutlookMsg As Object
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(0)
If Text1.Text <> "" Then
With objOutlookMsg
.To = Text1
'.Cc = "ifneed@copy.com"
.Subject = "checking 1 2 4 "
.Body = "This is the body of message"
.HTMLBody = "HTML version of message"
.Attachments.Add ("c:\Fastcartaskflow1.xls")
.send 'Let´s go!
MsgBox "Mail has been sent successfully", vbInformation, Mail
End With
Else
MsgBox "Please enter the Email Id", vbCritical, Email
End If
Set objOutlookMsg = Nothing
Set objOutlook = Nothing


Comments Pls
Credits: Shreejith G