+ Reply to Thread
Results 1 to 3 of 3

Print Failure - Default File Location

  1. #1
    Lee
    Guest

    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. #2
    Tom Ogilvy
    Guest

    Re: Print Failure - Default File Location

    ChDrive directoryname
    ChDir directoryname

    would be my guess
    --
    Regards,
    Tom Ogilvy



    "Lee" <Lee@discussions.microsoft.com> wrote in message
    news:E3136973-D630-46BC-9872-101279139EEB@microsoft.com...
    > 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. #3
    Lee
    Guest

    Re: 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" <Lee@discussions.microsoft.com> wrote in message
    > news:E3136973-D630-46BC-9872-101279139EEB@microsoft.com...
    > > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1