Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Opening files

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Opening files

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Opening files

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Opening files

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Opening files

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Opening files

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Opening files

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Opening files

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening files Sandy5590 Excel Discussion (Misc queries) 2 September 8th 09 02:03 PM
show most recent files first when opening excel files Anne` Excel Discussion (Misc queries) 5 January 23rd 08 01:54 AM
Opening Quattro Pro for Windows files (*.WB1 Files) using Excel 20 PoundMutt Excel Discussion (Misc queries) 1 June 20th 07 03:50 AM
How can I view files chronologically when opening multiple files Stevilsize Excel Discussion (Misc queries) 3 July 26th 05 12:49 AM
Opening Files Dave[_32_] Excel Programming 2 October 16th 03 06:25 PM


All times are GMT +1. The time now is 01:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"