Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
lee lee is offline
external usenet poster
 
Posts: 184
Default Print Failure - Default File Location

Below is a subset of some code that I have for a macro that opens and prints
files in a specific directory on a users C:\drive. The macro first counts
the files then opens them and prints the applicable pages. Everything work
fine unless a user has Tools-Option-General-Default File Location set to
anything other than the C:\drive (If it is set to the C:\drive, the directory
within the C:\drive doesn't seem to matter). If I set a watch on
directoryname it shows "C:\ProPupload\Do", but exits the count routine after
the first pass if there are no files in the non C:\drive default file
location, or the code bombs if there are files in the non C:\drive default
file location.

Is there something else I need to add to make sure that the pointer gets re
directed to C:\? Any help is greatly appreciated.

Sub aaaOpenandPrint()
Dim result As Integer
Dim noOfFiles As Integer
Dim arrayFiles() As String
Dim name_text As String
Dim count As Integer
Dim f As String
'define the location of the boe Do files
directoryname = "C:\ProPupload\Do\"
'get a list of the files to process in the DO folder
ChDir directoryname
count = 0
f = Dir$("*")
Do While Len(f) 0
count = count + 1
ReDim Preserve arrayFiles(1 To count)
arrayFiles(count) = f
f = Dir$()
Loop
noOfFiles = count
'---------------------------------------------------------------------
'open one file at a time and format the report
'
count = 1
Do While count < noOfFiles + 1
Workbooks.Open Filename:=arrayFiles(count)
printfilename = arrayFiles(count)
count = count + 1
'Start printing
Windows(printfilename).Activate



--
Thanks,

Lee
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Print Failure - Default File Location

ChDrive directoryname
ChDir directoryname

would be my guess
--
Regards,
Tom Ogilvy



"Lee" wrote in message
...
Below is a subset of some code that I have for a macro that opens and

prints
files in a specific directory on a users C:\drive. The macro first counts
the files then opens them and prints the applicable pages. Everything

work
fine unless a user has Tools-Option-General-Default File Location set to
anything other than the C:\drive (If it is set to the C:\drive, the

directory
within the C:\drive doesn't seem to matter). If I set a watch on
directoryname it shows "C:\ProPupload\Do", but exits the count routine

after
the first pass if there are no files in the non C:\drive default file
location, or the code bombs if there are files in the non C:\drive default
file location.

Is there something else I need to add to make sure that the pointer gets

re
directed to C:\? Any help is greatly appreciated.

Sub aaaOpenandPrint()
Dim result As Integer
Dim noOfFiles As Integer
Dim arrayFiles() As String
Dim name_text As String
Dim count As Integer
Dim f As String
'define the location of the boe Do files
directoryname = "C:\ProPupload\Do\"
'get a list of the files to process in the DO folder
ChDir directoryname
count = 0
f = Dir$("*")
Do While Len(f) 0
count = count + 1
ReDim Preserve arrayFiles(1 To count)
arrayFiles(count) = f
f = Dir$()
Loop
noOfFiles = count
'---------------------------------------------------------------------
'open one file at a time and format the report
'
count = 1
Do While count < noOfFiles + 1
Workbooks.Open Filename:=arrayFiles(count)
printfilename = arrayFiles(count)
count = count + 1
'Start printing
Windows(printfilename).Activate



--
Thanks,

Lee



  #3   Report Post  
Posted to microsoft.public.excel.programming
lee lee is offline
external usenet poster
 
Posts: 184
Default Print Failure - Default File Location

Thanks!!!! I put in ChDrive "C" before the ChDir ands it works great.
Didn't realize that ChDir didn't change the default drive as well. This will
make a couple of users very happy. Thanks again.

--
Lee Kirts


"Tom Ogilvy" wrote:

ChDrive directoryname
ChDir directoryname

would be my guess
--
Regards,
Tom Ogilvy



"Lee" wrote in message
...
Below is a subset of some code that I have for a macro that opens and

prints
files in a specific directory on a users C:\drive. The macro first counts
the files then opens them and prints the applicable pages. Everything

work
fine unless a user has Tools-Option-General-Default File Location set to
anything other than the C:\drive (If it is set to the C:\drive, the

directory
within the C:\drive doesn't seem to matter). If I set a watch on
directoryname it shows "C:\ProPupload\Do", but exits the count routine

after
the first pass if there are no files in the non C:\drive default file
location, or the code bombs if there are files in the non C:\drive default
file location.

Is there something else I need to add to make sure that the pointer gets

re
directed to C:\? Any help is greatly appreciated.

Sub aaaOpenandPrint()
Dim result As Integer
Dim noOfFiles As Integer
Dim arrayFiles() As String
Dim name_text As String
Dim count As Integer
Dim f As String
'define the location of the boe Do files
directoryname = "C:\ProPupload\Do\"
'get a list of the files to process in the DO folder
ChDir directoryname
count = 0
f = Dir$("*")
Do While Len(f) 0
count = count + 1
ReDim Preserve arrayFiles(1 To count)
arrayFiles(count) = f
f = Dir$()
Loop
noOfFiles = count
'---------------------------------------------------------------------
'open one file at a time and format the report
'
count = 1
Do While count < noOfFiles + 1
Workbooks.Open Filename:=arrayFiles(count)
printfilename = arrayFiles(count)
count = count + 1
'Start printing
Windows(printfilename).Activate



--
Thanks,

Lee




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
Default file location Marvin Excel Discussion (Misc queries) 1 April 16th 08 08:46 PM
Default file location hmburg52 Setting up and Configuration of Excel 2 January 25th 07 10:02 AM
default file location maryj Excel Discussion (Misc queries) 2 March 3rd 05 06:09 PM
Add a default location for print to file in Excel. valders Excel Discussion (Misc queries) 0 December 30th 04 11:19 PM
Default File Location Kevin Excel Programming 1 November 9th 04 10:07 AM


All times are GMT +1. The time now is 11:32 PM.

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

About Us

"It's about Microsoft Excel"