Posts by JF

    Re: Save An Attachment To A Folder


    [QUOTE=Mavyak]


    This code goes in the ThisOutlookSession module....QUOTE]


    OK I put the code in the This OutlookSesson module. It initiall errored on

    Code
    Dim objNS As NameSpace
        Set objNS = Application.GetNamespace("MAPI")


    I changed to

    Code
    Dim myNameSpace As Outlook.NameSpace
        Dim myFolder As Outlook.MAPIFolder


    No loger get the error. However, nothing happens (Yes I did close and restart outlook)....

    Re: Save An Attachment To A Folder


    Quote from Mavyak

    This works in Outlook 2000:



    That code goes in the ThisOutlookSession module. Whenever an email is received from Mavyak, the code specified will run.


    Looks like some of the variables are the same as mine. Here is my code, how do I modify it to run continusly:


    Re: Save An Attachment To A Folder


    OK, I found the code to rete the folder and have it working. Now I just need to know how to have my code automatically run all the time (be "listening" ) so that when the email is received and moved into the specified folder, the attachment will automatically get saved.

    Re: Save An Attachment To A Folder


    It may be easier to add the date up front.....


    One other question: At present I have it saving the files in a predefinded folder. How would I have it crete a folder based on the date and then save the files to that folder? I.e if today is 10/5/2007 it creates the folder 100507 and then saves the files into that folder.

    Re: Save An Attachment To A Folder


    Thanks ANdy, that worked.


    Now I have one other issue I need assistance with.


    Ihave the following line:

    Code
    myAttachment.SaveAsFile "H:\Kana_Reports\Daily\Daily_Received\" & myAttachment.FileName & _Format(Now(), "mm_dd_yyyy")


    while this does save the attachment and does add the date to the end, it is adding it after the file type. i.e


    file1.xls10_05_2007 or file2.csv10_05_2007


    How do I make it add it prior to the file type (and add an "_" )? i.e


    file1_10_05_2007.xls or file2_10_05_2007_.csv



    One other question: At present I have it saving the files in a predefinded folder. How would I have it crete a folder based on the date and then save the files to that folder? I.e if today is 10/5/2007 it creates the folder 100507 and then saves the files into that folder.

    I found the code to use for saving an attachment in an email to an external folder. (could not post to that threat - http://www.ozgrid.com/forum/showthread.php?t=59353 - so had to create a new one) However I am getting an error. The line of code is:


    Code
    Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
        Set myFolder = myFolder.Folders("Daily Reports")


    The second line is the one with the error. It is a runtime error indicating an object can not be found. The folder is actually a sub folder of a sub folder or a Folder called My Folders. The "My Folders" folder is not a sub folder of the main inbox but a sibling (for lack of better words)


    I tried to change the first line to:

    Code
    Set myFolder = myNameSpace.GetDefaultFolder(olFolderMyFolders)


    but then received the error on that line. If it helps, here is the set up of my outlook if it helps:


    Mailbox
    -Inbox
    -My Folders
    -- Inbound Items
    --- Reports
    ---- Daily Reports


    The email with the attachments are in the "Daily Reports" sub folder


    Any Help wouold be appreciated.

    Re: Removing Unwanted Returns


    Thanks. In this case the =clean(a1) would be fine.
    But I did get it to work with the substitute() as follows:


    =substitute(a1,char(13)&char(10),"",1)

    Re: Removing Unwanted Returns


    Thanks for the info. The code function indicated that the characters were infact a char(13) and a char(10) (one of each). so I am not sure why the substitue function did not work. However I did get this to work:


    Code
    =LEFT(A3,FIND(CHAR(13),A3,1)-1)

    I have a data file that is comma delimited (that I bring into excel). one section of the file contains several pices of information seperated by what appears to be a carriage return (shows up as a square box) I can use the find & repace to break it into seperate section. However I can not get rid of the carriage return.


    Does anyone know how I can get rid of it?


    I have tried the following formula without success:

    Code
    =substitute(a1,CHAR(10),"|") 
    
    
    =substitute(a1,CHAR(13),"|")

    Re: Use Data From Form In Query



    did you try

    Code
    DoCmd.OpenForm "QA_Check_View_Report", acNormal, , Lab_ID = [CNMT_Temp_Query]![LabID]

    I am tring to create a table via an SQL command (vs the create table wizzard). Is there a way to create a numeric field with a limit of 5 digits in access? I know with ANSI SQL it would be number(5) but with access that did not work I tried the below but it errors on the "zip" line


    Code
    create table employee
     (emp_id varchar(9) not null,
      last_Name varchar(20) not null,
      first_name varchar(20) not null,
      st_address varchar(30) not null,
      city varchar(20) not nnull,
      state char(2) not null,
      zip Integer(5) not null,
      date_hire date);



    The code below works but does not limit the "zip" field to 5 digits



    Code
    create table employee
     (emp_id varchar(9) not null,
      last_Name varchar(20) not null,
      first_name varchar(20) not null,
      st_address varchar(30) not null,
      city varchar(20) not nnull,
      state char(2) not null,
      zip Integer not null,
      date_hire date);



    Can this be done or does the limiting have to be done via validation code in a module etc? I know that if I made it a character field I can limit it but then ahve to deal with the possibility of letters .

    Re: Copy & Paste Data Based On Current Month


    The code can be shortend as follows:


    if you look at the code, the line

    Code
    tmp=Month(now())


    calculates the numeric value of the current month (for Jun it results in 6). To check that it is working correctly, unremark the line

    Code
    MsgBox(tmp)

    by removing the ' then when you run the macro, it will pop up a box showing the number. line

    Code
    tmp2=tmp+5

    added 5 to the tmp number becasue in the sample you posted, your graph data started in column F which is the 6th column. The first 5 columns were your static data. so we need to add 5 to the number of the month to get the correct column number to post the data into. It worked correctly on mine. It it was posting to the July column, then either you have one less static column or possibly the date on your computer is off. by unremarking the MsgBox lines, it will show where the issue may be.

    Re: Use Macro To Copy And Paste Data Based On Current Month


    Try the following (it is not the most elegant but does what I think you want)



    I believe the code can be combined but can not remember how to get the pastespecial to work.

    Code
    Range("D70").Copy Destination:=Cells(2, tmp2)


    not sure how to get the pastespecial into the line above to paste just the value

    Re: Future Interest


    Try doing a search of the built in excel help for future value or financial functions. It will give a complete list of the different formulas/functions available with examples.

    Re: Find Text String And Report Back Data In Unknown Number Of Rows



    From your sample above, why not just do a sort on the names, this will group them together like you have them in the "report" two output you've shown.

    Re: Random Number Generator Macro


    Quote from daamyour

    What can I do to eliminat the selection marque for each macro and prevent the sheet flip-flop?


    Try putting:


    Code
    Application.ScreenUpdating = False


    at the top of your macro


    and

    Code
    Application.ScreenUpdating = True


    at the end

    Re: Delete Rows Not Meeting Criteria


    Are the 5 names static or do they need to change?


    If they are static, you could set up a named range and then use a formula to check the columns.


    You could use a working column and a formula to indicate which rows to keep.



    So if your names are in column A & B list your desired names in J1-J5


    then use the following formula in Col C:


    =IF(AND(ISERROR(MATCH(A1,$J$1:$J$5,0)),ISERROR(MATCH(B1,$J$1:$J$5,0))),"N","Y")


    This could be copied down Either manually or via vba, then sort the list and remove any lines with a "N" in col C


    You can do it via vba as follows:

    Re: Open Files With Number Extensions


    I am guessing that the file name is the date the file was created (or poertains to). If this is correct, is it always the previous day, two days prior etc. If so, you can create the file name based on the current date (minus 1, 2, etc) and use the text value of that. and append the .xls to the end of it.

    Re: Manipulating Charts Without Activating


    Try this:

    Code
    Sub MyTest()
    Dim mychart As ChartObject
    Set mychart = Sheet1.ChartObjects("chart 1")
    With mychart.Chart
        .ChartType = xlBarClustered
        .PlotBy = xlColumns
        
    End With
    End Sub