Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,645

    help_me may have been thrown by your comment "I don't think the CSV itself had any code in it." A CSV file is just a text file, it cannot 'have code'. Waiting to see what happens with your testing at work.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  2. #17
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    well I haven't really been paying much attention to this thread June. This whole thing just seems to be *way* out of the norm of working with office products the way they should be.

    It just looks as though it takes too much thought to figure out what we're up to here. So I gave up!

  3. #18
    togo is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    83
    Thought I'd let you know it worked!

    the file got saved in file format 52 (.xlsm) macro enabled. The major catch seems to be that Excel has to be open for this procedure, which is supposed to be automated, to work. Probably because macro security settings. I'll try open Excel up using the batch file as well before calling this sub/function.

  4. #19
    togo is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    83
    I don't know if a new thread should be started or not, but I still can't run macros from Access, although when Access opens up the workbook through Excel the macros show up in the modules.

    Keep getting error message "run-time error '1004':"
    Cannot run the macro 'C:\Program Files\Microsoft Office\Office14\XLSTART\Personal.xlsm!Macro1'. The macro may not be available in this workbook or all macros may be disabled.

    Again, my macro security settings have been completely lowered, they show up in the document, and using this code:

    Code:
    Function Macro22()
    On Error GoTo Macro22_Err
        Dim appExcel1 As Excel.Application
        On Error Resume Next
        AppActivate "Microsoft Excel"
        
        If Err Then
        Shell "c:\Program Files\Microsoft Office\Office\" _
            & "Excel /Automation", vbHide
        AppActivate "Microsoft Excel"
        End If
        On Error GoTo 0
        
        Set appExcel1 = GetObject(, "Excel.Application")
        appExcel1.Workbooks.Open FileName:="c:\pmi\temp3.xlsx"
        
        strXLSMPath = "c:\PMI\temp3.xlsm"
        strCSVPath = "c:\PMI\temp1.csv"
        
        appExcel1.ActiveWorkbook.SaveAs FileName:=Left(strXLSMPath, Len(strCSVPath) - 3) & "xlsm" _
        , FileFormat:=52
        
        appExcel1.Workbooks.Open FileName:="c:\pmi\temp3.xlsm"
        appExcel1.Application.Run "C:\Program Files\Microsoft Office\Office14\XLSTART\Personal.xlsm!Macro1"
    Macro22_Exit:
        Exit Function
    Macro22_Err:
        MsgBox Error$
        Resume Macro22_Exit
    End Function
    (forgive the laziness on replacing some variables here, for example we're no longer using CSV files just changing an XLSX file to an XLSM file)

    the macro is stored in the template file of course. Temp1,2 and 3 are basically made from scratch.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Execute Excel Macro from Access failing
    By dcgrove in forum Programming
    Replies: 1
    Last Post: 12-22-2011, 02:14 PM
  2. Excel Import Macro Help in Access
    By vennies83 in forum Import/Export Data
    Replies: 5
    Last Post: 11-02-2011, 09:24 AM
  3. Converting Excel Macro into Access Module
    By diddyville in forum Modules
    Replies: 1
    Last Post: 03-28-2011, 07:02 PM
  4. Replies: 1
    Last Post: 10-15-2010, 06:09 AM
  5. Running excel macro from access
    By timpepu in forum Programming
    Replies: 1
    Last Post: 02-26-2010, 11:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums