i have a problem with my code... i use this code to open an excel and manipulate the data
Dim xl3 As Excel.Application Dim xl3sheet As Excel.Worksheet Dim xl3wbook As Excel.Workbook Dim FilNam As String Me.CommonDialog1.ShowOpen FilNam = Me.CommonDialog1.Filename If Me.CommonDialog1.Filename <> "" Or Me.CommonDialog1.Filename <> ".xls" Then Set xl3 = CreateObject("Excel.Application") Set xl3wbook = xl3.Workbooks.Open(FilNam) Set xl3sheet = xl3wbook.Sheets.Item(1) xl3.Worksheets("SYS_SUMM").Activate xl3.Range("G25:L27").Copy ....... 'manipulating data Application.CutCopyMode = False xl15.DisplayAlerts = False xl15.Workbooks.Close xl15.Quit Set xl15 = Nothing Set xl15wbook = Nothing Set xl15sheet = Nothing End If End Sub
it works well accept a few things
when the browse menu opened so i can choose which file to manipulate
if i double click the file i want to open = its open and good
if i click a file once and click button open = its open and good
if i didnt click anything and close the open window = its error to my application
if i click a file and click cancel = its error to my application
how do i fix this?
another question is when the commondialog opened. how can i set it so user can only choose excel file only.this is to reduce human error.