How to Browse file and open select file vba code

How to Browse file and open select file vba code
Below vba code
--------------------------------------------------------------------------------------------------------
Sub browsefileopen()
'below browse file code

myfile = Application.GetOpenFilename(, , "Browse for File")

'browse filename update with file location in active sheet.
ThisWorkbook.Sheets("sheet1").Range("a2") = myfile


'select browse  file open code
Workbooks.Open myfile


End Sub

-----------------------------------------------------------------------------------------------------------------

This workbook contains links to other data sources-Excel vba code



Question-How to Disable alert box  This workbook contains links to other data sources Excel       vba code

worning altert-1
This workbook contains links to other data sources



Worning Alert-2
This workbook contains one or more links that cannot be updated


Answer Solution-' Disaple Update link alert prompt box

Try below code:-


Application.AskToUpdateLinks = False
Application.DisplayAlerts = False


Try below code-

 Workbooks.Open Filename:=FullFileName, UpdateLinks:=0
Try below code-

Application.ScreenUpdating = False


How to Move Excel sheet Data to Other workbook

Example1:-Move Excel sheet Data to Other workbook

Copy Below Code and Paste in Module


Sub movefileotherworkbook()
Workbooks.Open Filename:="C:\NitinVbaAppAMD\nitin1.xlsx"
ActiveSheet.Range("A2:F4").Copy

Workbooks.Open Filename:="C:\NitinVbaAppAMD\nitin2.xlsx"
'eColumn = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
'If eColumn >= 1 Then eColumn = eColumn + 1
ActiveSheet.Cells(1, 1).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, Skipblanks:=False, Transpose:=True
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.CutCopyMode = False

End Sub

Note:-Green Highlight you can Update/change 
Note this code not paste nitin1 and nitin2 please paste another for run macro.



how to run Macro Excel file from vbs script.

VBS script Example.

how to run Macro Excel file from vbs script.

Step1- Open Notepad
>>paste below code>>File Save filename.vbs and run vbs file.

----------------------------------------------------------------------------

Set ObjExcel=CreateObject("Excel.Application")
objExcel.Application.Run"'C:\NitinVbaAppST\nitintest.xlsm'!Module1.msgtest"
ObjExcel.DisplayAlerts=False
ObjExcel.Application.Quit
Set ObjExcel=Nothing
---------------------------------------------------------------------------------


please note

msgtest is macro function name which use in nitintest.xlsm fil

Excel sound play code:


Excel sound play code:-


Option Explicit

Private Declare Function sndPlaySound32 Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName _
As String, ByVal uFlags As Long) As Long

Private Sub Worksheet_Change(ByVal Target As Range)

    Dim Cell As Range
    Dim PlaySound As Boolean

    If Target.Column = 3 Then
        For Each Cell In Target
            'If WorksheetFunction.IsNA(Cell.Value) Then
            If Cell.Value = "line" Then
                PlaySound = True
            End If
        Next

        If PlaySound Then
            Call sndPlaySound32("C:\windows\media\Line.wav", 1)
        End If



    End If
End Sub

Break Link Vba Code in excel

Below BreakLink code download-
Please Paste Code in modul


Sub BreakLinks()
Dim iii As Variant

 Dim astrLinks As Variant

    ' Define variable as an Excel link type.
    astrLinks = ActiveWorkbook.LinkSources(Type:=xlLinkTypeExcelLinks)

    ' Break the first link in the active workbook.
    For iii = 1 To UBound(astrLinks)

   
    ActiveWorkbook.BreakLink _
        Name:=astrLinks(iii), _
        Type:=xlLinkTypeExcelLinks
Next iii
End Sub

Outlook Mail send Code

Outlook mail send code

Below code copy and paste module
click here for download file:-    Outlook send mail file
_______________________________________________

Sub Send_Mail()

Dim outlookobj As Outlook.Application
Dim mitem As Outlook.MailItem
Set outlookobj = New Outlook.Application
Set mitem = outlookobj.CreateItem(olMailItem)
With mitem

.To = "nppsnee@gmail.com"
.Subject = "this is testing"
.Body = "this is computer outlook mail"
.Display
End With

End Sub
__________________________________________________

About Me

author Click here for Connect FB

Click here for Linkedin

Related Post No.

Powered by Blogger.

Contact Form

Name

Email *

Message *

Search This Blog

Recent Posts

Breaking

Recent Posts

Trending Topic

Breaking

Related Post No.

Pages