Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I have the following sub that works great for regular xls files. Now I need to use the similar sub but to open excel files that has macros. I am trying to open xls files without having the macro to proceed. Is there a way to do this by amending the following code? The purpose is to open files and then consolidate them into one. Thank you for your help. Sub openQuarterlyFiles() Dim selectedFile As String Dim wbToOpen As Integer, wsCount As Integer With objWsQBRfreeB lastline = Range("A32000").End(xlUp).Row For wbToOpen = 1 To 10 'display dialog asking user to select a file selectedFile = Application.GetOpenFilename( _ "Files (*.xls),*.xls", , "Select your Monthly Free Balance file", , False) 'check if cancel selected then open If selectedFile = "False" Then MsgBox "You choose to interrupt loading files." Call closeQBRFreeBalance Exit For Else Workbooks.OpenText fileName:=selectedFile Call openDelimitedFile(selectedFile) End If wsCount = Workbooks(1).Worksheets.count Workbooks(2).Activate Sheets(1).Move After:=Workbooks(1).Sheets(wsCount) Next End With processQfiles End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Am not sure but you may just want to turn off events and alerts.
Application.DisplayAlerts = False ' this will turn off all alerts ' and allow opening book with macros on Application.EnableEvents = False ' this will prevent all event macros from running ' YOUR CODE TO OPEN WORKBOOK ' Reset to "Normal" Application.DisplayAlerts = True Application.EnableEvents = True -- steveB Remove "AYN" from email to respond "Daniel" wrote in message ... Hello, I have the following sub that works great for regular xls files. Now I need to use the similar sub but to open excel files that has macros. I am trying to open xls files without having the macro to proceed. Is there a way to do this by amending the following code? The purpose is to open files and then consolidate them into one. Thank you for your help. Sub openQuarterlyFiles() Dim selectedFile As String Dim wbToOpen As Integer, wsCount As Integer With objWsQBRfreeB lastline = Range("A32000").End(xlUp).Row For wbToOpen = 1 To 10 'display dialog asking user to select a file selectedFile = Application.GetOpenFilename( _ "Files (*.xls),*.xls", , "Select your Monthly Free Balance file", , False) 'check if cancel selected then open If selectedFile = "False" Then MsgBox "You choose to interrupt loading files." Call closeQBRFreeBalance Exit For Else Workbooks.OpenText fileName:=selectedFile Call openDelimitedFile(selectedFile) End If wsCount = Workbooks(1).Worksheets.count Workbooks(2).Activate Sheets(1).Move After:=Workbooks(1).Sheets(wsCount) Next End With processQfiles End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
OpenText is used for opening text files yet you say you are opening XLS
files. You are calling a subroutine with no explanation of what it does. What do you mean by "without having the macro to proceed. " Perhaps a little clarity on what your issue is would be helpful. -- Regards, Tom Ogilvy "Daniel" wrote in message ... Hello, I have the following sub that works great for regular xls files. Now I need to use the similar sub but to open excel files that has macros. I am trying to open xls files without having the macro to proceed. Is there a way to do this by amending the following code? The purpose is to open files and then consolidate them into one. Thank you for your help. Sub openQuarterlyFiles() Dim selectedFile As String Dim wbToOpen As Integer, wsCount As Integer With objWsQBRfreeB lastline = Range("A32000").End(xlUp).Row For wbToOpen = 1 To 10 'display dialog asking user to select a file selectedFile = Application.GetOpenFilename( _ "Files (*.xls),*.xls", , "Select your Monthly Free Balance file", , False) 'check if cancel selected then open If selectedFile = "False" Then MsgBox "You choose to interrupt loading files." Call closeQBRFreeBalance Exit For Else Workbooks.OpenText fileName:=selectedFile Call openDelimitedFile(selectedFile) End If wsCount = Workbooks(1).Worksheets.count Workbooks(2).Activate Sheets(1).Move After:=Workbooks(1).Sheets(wsCount) Next End With processQfiles End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is with pleasure. The code listed do open text file even if they bear .xls
files (comma delimited or whatever). I take these files and format them using a excel addin I created. At the end the new file will be a xls file containing code in the thisworkbook, two modules and a reference to an addin. I would like to consolidate those files and I am stuck with the fact that the macros of the file I am opening wants to run and I don't need them to be functional in the consolidation I need to do (but I don't want to remove them in the original as they are still usefull). I have tried Steve Bell suggestion, it seems to be working. I find that it does take a long time to open files (10 seconds for the 1st and 5th file). Thank you. __________ "Tom Ogilvy" wrote in message ... OpenText is used for opening text files yet you say you are opening XLS files. You are calling a subroutine with no explanation of what it does. What do you mean by "without having the macro to proceed. " Perhaps a little clarity on what your issue is would be helpful. -- Regards, Tom Ogilvy "Daniel" wrote in message ... Hello, I have the following sub that works great for regular xls files. Now I need to use the similar sub but to open excel files that has macros. I am trying to open xls files without having the macro to proceed. Is there a way to do this by amending the following code? The purpose is to open files and then consolidate them into one. Thank you for your help. Sub openQuarterlyFiles() Dim selectedFile As String Dim wbToOpen As Integer, wsCount As Integer With objWsQBRfreeB lastline = Range("A32000").End(xlUp).Row For wbToOpen = 1 To 10 'display dialog asking user to select a file selectedFile = Application.GetOpenFilename( _ "Files (*.xls),*.xls", , "Select your Monthly Free Balance file", , False) 'check if cancel selected then open If selectedFile = "False" Then MsgBox "You choose to interrupt loading files." Call closeQBRFreeBalance Exit For Else Workbooks.OpenText fileName:=selectedFile Call openDelimitedFile(selectedFile) End If wsCount = Workbooks(1).Worksheets.count Workbooks(2).Activate Sheets(1).Move After:=Workbooks(1).Sheets(wsCount) Next End With processQfiles End Sub |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yes, Application.EnableEvents does stop the Workbook_Open macro from running
and also stops any other Excel type library events from firing. -- Regards, Tom Ogilvy "Daniel" wrote in message ... Is with pleasure. The code listed do open text file even if they bear ..xls files (comma delimited or whatever). I take these files and format them using a excel addin I created. At the end the new file will be a xls file containing code in the thisworkbook, two modules and a reference to an addin. I would like to consolidate those files and I am stuck with the fact that the macros of the file I am opening wants to run and I don't need them to be functional in the consolidation I need to do (but I don't want to remove them in the original as they are still usefull). I have tried Steve Bell suggestion, it seems to be working. I find that it does take a long time to open files (10 seconds for the 1st and 5th file). Thank you. __________ "Tom Ogilvy" wrote in message ... OpenText is used for opening text files yet you say you are opening XLS files. You are calling a subroutine with no explanation of what it does. What do you mean by "without having the macro to proceed. " Perhaps a little clarity on what your issue is would be helpful. -- Regards, Tom Ogilvy "Daniel" wrote in message ... Hello, I have the following sub that works great for regular xls files. Now I need to use the similar sub but to open excel files that has macros. I am trying to open xls files without having the macro to proceed. Is there a way to do this by amending the following code? The purpose is to open files and then consolidate them into one. Thank you for your help. Sub openQuarterlyFiles() Dim selectedFile As String Dim wbToOpen As Integer, wsCount As Integer With objWsQBRfreeB lastline = Range("A32000").End(xlUp).Row For wbToOpen = 1 To 10 'display dialog asking user to select a file selectedFile = Application.GetOpenFilename( _ "Files (*.xls),*.xls", , "Select your Monthly Free Balance file", , False) 'check if cancel selected then open If selectedFile = "False" Then MsgBox "You choose to interrupt loading files." Call closeQBRFreeBalance Exit For Else Workbooks.OpenText fileName:=selectedFile Call openDelimitedFile(selectedFile) End If wsCount = Workbooks(1).Worksheets.count Workbooks(2).Activate Sheets(1).Move After:=Workbooks(1).Sheets(wsCount) Next End With processQfiles End Sub |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Daniel,
Glad it helped. Are the slow files very large, lots of formulas, have external references, etc. If so - you can turn Calculation on/off, Update exterenal references on/off, etc. -- steveB Remove "AYN" from email to respond "Daniel" wrote in message ... Is with pleasure. The code listed do open text file even if they bear .xls files (comma delimited or whatever). I take these files and format them using a excel addin I created. At the end the new file will be a xls file containing code in the thisworkbook, two modules and a reference to an addin. I would like to consolidate those files and I am stuck with the fact that the macros of the file I am opening wants to run and I don't need them to be functional in the consolidation I need to do (but I don't want to remove them in the original as they are still usefull). I have tried Steve Bell suggestion, it seems to be working. I find that it does take a long time to open files (10 seconds for the 1st and 5th file). Thank you. __________ "Tom Ogilvy" wrote in message ... OpenText is used for opening text files yet you say you are opening XLS files. You are calling a subroutine with no explanation of what it does. What do you mean by "without having the macro to proceed. " Perhaps a little clarity on what your issue is would be helpful. -- Regards, Tom Ogilvy "Daniel" wrote in message ... Hello, I have the following sub that works great for regular xls files. Now I need to use the similar sub but to open excel files that has macros. I am trying to open xls files without having the macro to proceed. Is there a way to do this by amending the following code? The purpose is to open files and then consolidate them into one. Thank you for your help. Sub openQuarterlyFiles() Dim selectedFile As String Dim wbToOpen As Integer, wsCount As Integer With objWsQBRfreeB lastline = Range("A32000").End(xlUp).Row For wbToOpen = 1 To 10 'display dialog asking user to select a file selectedFile = Application.GetOpenFilename( _ "Files (*.xls),*.xls", , "Select your Monthly Free Balance file", , False) 'check if cancel selected then open If selectedFile = "False" Then MsgBox "You choose to interrupt loading files." Call closeQBRFreeBalance Exit For Else Workbooks.OpenText fileName:=selectedFile Call openDelimitedFile(selectedFile) End If wsCount = Workbooks(1).Worksheets.count Workbooks(2).Activate Sheets(1).Move After:=Workbooks(1).Sheets(wsCount) Next End With processQfiles End Sub |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How do I do tell excel not to calculate before opening the file?
Thanks _______________ "STEVE BELL" wrote in message news:u1Wxe.5494$Yb4.110@trnddc08... Daniel, Glad it helped. Are the slow files very large, lots of formulas, have external references, etc. If so - you can turn Calculation on/off, Update exterenal references on/off, etc. -- steveB Remove "AYN" from email to respond "Daniel" wrote in message ... Is with pleasure. The code listed do open text file even if they bear .xls files (comma delimited or whatever). I take these files and format them using a excel addin I created. At the end the new file will be a xls file containing code in the thisworkbook, two modules and a reference to an addin. I would like to consolidate those files and I am stuck with the fact that the macros of the file I am opening wants to run and I don't need them to be functional in the consolidation I need to do (but I don't want to remove them in the original as they are still usefull). I have tried Steve Bell suggestion, it seems to be working. I find that it does take a long time to open files (10 seconds for the 1st and 5th file). Thank you. __________ "Tom Ogilvy" wrote in message ... OpenText is used for opening text files yet you say you are opening XLS files. You are calling a subroutine with no explanation of what it does. What do you mean by "without having the macro to proceed. " Perhaps a little clarity on what your issue is would be helpful. -- Regards, Tom Ogilvy "Daniel" wrote in message ... Hello, I have the following sub that works great for regular xls files. Now I need to use the similar sub but to open excel files that has macros. I am trying to open xls files without having the macro to proceed. Is there a way to do this by amending the following code? The purpose is to open files and then consolidate them into one. Thank you for your help. Sub openQuarterlyFiles() Dim selectedFile As String Dim wbToOpen As Integer, wsCount As Integer With objWsQBRfreeB lastline = Range("A32000").End(xlUp).Row For wbToOpen = 1 To 10 'display dialog asking user to select a file selectedFile = Application.GetOpenFilename( _ "Files (*.xls),*.xls", , "Select your Monthly Free Balance file", , False) 'check if cancel selected then open If selectedFile = "False" Then MsgBox "You choose to interrupt loading files." Call closeQBRFreeBalance Exit For Else Workbooks.OpenText fileName:=selectedFile Call openDelimitedFile(selectedFile) End If wsCount = Workbooks(1).Worksheets.count Workbooks(2).Activate Sheets(1).Move After:=Workbooks(1).Sheets(wsCount) Next End With processQfiles End Sub |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Daniel,
wrap your code with this: Application.Calculation = xlCalculationManual ' your code Application.Calculation = xlCalculationAutomatic p.s. Go to the VBE Editor Select "Tools" menu Select "Options" Select "Editor" tab Check "Auto List Members" Now as you write code - most times when you add a "." or a space, or an "=" a dropdown will appear with choices. Try this by typing Application. and see what happens... takes a little practice but it is very helpful... -- steveB Remove "AYN" from email to respond "Daniel" wrote in message ... How do I do tell excel not to calculate before opening the file? Thanks _______________ "STEVE BELL" wrote in message news:u1Wxe.5494$Yb4.110@trnddc08... Daniel, Glad it helped. Are the slow files very large, lots of formulas, have external references, etc. If so - you can turn Calculation on/off, Update exterenal references on/off, etc. -- steveB Remove "AYN" from email to respond "Daniel" wrote in message ... Is with pleasure. The code listed do open text file even if they bear .xls files (comma delimited or whatever). I take these files and format them using a excel addin I created. At the end the new file will be a xls file containing code in the thisworkbook, two modules and a reference to an addin. I would like to consolidate those files and I am stuck with the fact that the macros of the file I am opening wants to run and I don't need them to be functional in the consolidation I need to do (but I don't want to remove them in the original as they are still usefull). I have tried Steve Bell suggestion, it seems to be working. I find that it does take a long time to open files (10 seconds for the 1st and 5th file). Thank you. __________ "Tom Ogilvy" wrote in message ... OpenText is used for opening text files yet you say you are opening XLS files. You are calling a subroutine with no explanation of what it does. What do you mean by "without having the macro to proceed. " Perhaps a little clarity on what your issue is would be helpful. -- Regards, Tom Ogilvy "Daniel" wrote in message ... Hello, I have the following sub that works great for regular xls files. Now I need to use the similar sub but to open excel files that has macros. I am trying to open xls files without having the macro to proceed. Is there a way to do this by amending the following code? The purpose is to open files and then consolidate them into one. Thank you for your help. Sub openQuarterlyFiles() Dim selectedFile As String Dim wbToOpen As Integer, wsCount As Integer With objWsQBRfreeB lastline = Range("A32000").End(xlUp).Row For wbToOpen = 1 To 10 'display dialog asking user to select a file selectedFile = Application.GetOpenFilename( _ "Files (*.xls),*.xls", , "Select your Monthly Free Balance file", , False) 'check if cancel selected then open If selectedFile = "False" Then MsgBox "You choose to interrupt loading files." Call closeQBRFreeBalance Exit For Else Workbooks.OpenText fileName:=selectedFile Call openDelimitedFile(selectedFile) End If wsCount = Workbooks(1).Worksheets.count Workbooks(2).Activate Sheets(1).Move After:=Workbooks(1).Sheets(wsCount) Next End With processQfiles End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Opening files | Excel Discussion (Misc queries) | |||
show most recent files first when opening excel files | Excel Discussion (Misc queries) | |||
Opening Quattro Pro for Windows files (*.WB1 Files) using Excel 20 | Excel Discussion (Misc queries) | |||
How can I view files chronologically when opening multiple files | Excel Discussion (Misc queries) | |||
Opening Files | Excel Programming |