Results 1 to 3 of 3
  1. #1
    DavidK111 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    18

    Where to place VBA to add additional steps to a macro

    I am new to using VBA in Access. I was wondering what steps I need to take so that I can perform the following after a macro that I have already built completes. In other words, I need to do this as the final step after the Access Macro completes:



    1. Open a particular txt file.
    2. Insert text at the end of the first cell in the file
    3. Save and close the file.

    I have already created this step in Excel and the VBA is shown below. I am hoping I can simply paste this into a location in Access so that the macro in Access and that final step can all occur in a single step.

    Thanks for any direction you can provide.

    Here is the VBA from Excel:

    Sub HalfTest2()
    '
    ' HalfTest2 Macro
    '


    '
    Workbooks.OpenText FileName:= _
    "C:\Users\Tim\OpenDrive\Access DB Exports\007_HalfFileAV2.txt", _
    Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
    xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
    Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
    Array(2, 1), Array(3, 2), Array(4, 2), Array(5, 2), Array(6, 1), Array(7, 1)), _
    TrailingMinusNumbers:=True
    ActiveCell.FormulaR1C1 = _
    "Action (SiteID=US|Country=US|Currency=USD|ListingType=Hal f|Location=US|ListingDuration=GTC)"
    Range("A2").Select
    ActiveWorkbook.Save
    ActiveWindow.Close
    Workbooks.OpenText FileName:= _
    "C:\Users\Tim\OpenDrive\Access DB Exports\007_HalfFileAV2.txt", _
    Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
    xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
    Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
    Array(2, 1), Array(3, 2), Array(4, 2), Array(5, 2), Array(6, 1), Array(7, 1)), _
    TrailingMinusNumbers:=True
    ActiveCell.FormulaR1C1 = _
    "Action (SiteID=US|Country=US|Currency=USD|ListingType=Hal f|Location=US|ListingDuration=GTC)"
    Range("A2").Select
    ActiveWorkbook.Save
    ActiveWorkbook.Save
    ActiveWindow.Close
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    CLARITY:
    do you want the vb to run from Access but do this action in excel sheet?
    or
    run the same function from access IN access table?

  3. #3
    DavidK111 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    18
    Thanks for the reply. I want the vb to run from Access but do this action in an excel sheet (i.e., it will be in cell A1 in a text file).

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 03-11-2014, 09:29 AM
  2. help with next steps mysql
    By Hockeyguy1924 in forum SQL Server
    Replies: 1
    Last Post: 06-15-2012, 05:13 PM
  3. Guiding Through Steps (Opinion Please)
    By Dalagrath in forum Forms
    Replies: 1
    Last Post: 04-01-2011, 05:02 PM
  4. New to access, looking for steps to complete
    By iamyourdemize in forum Access
    Replies: 1
    Last Post: 05-21-2010, 02:19 PM
  5. Replies: 0
    Last Post: 10-14-2009, 02:49 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