Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

calling specific xcell file from vb

  • 26-08-2004 6:50pm
    #1
    Registered Users, Registered Users 2 Posts: 2,587 ✭✭✭


    Looking to call a specific file from VB and insert info into data.
    I can open excel in general and write to a work sheet no problems but I want to write the data into a certain file:
    Dim objExcel As excel.Application
    Dim objWorkbook As excel.Workbook
    Dim objWorksheet As excel.Worksheet
    
    'Start the excel COM and make it visible.
    Set objExcel = GetObject("", "excel.application")
        objExcel.Visible = True
        
    'Start a workbook.
    Set objWorkbook = objExcel.Workbooks.Add
    
    'Turn off the alerts, otherwise user will have to confirm my actions.
        objExcel.DisplayAlerts = False
    
    'Depending on the users excel's settings, there could be many worksheet when starting a workbook.
    'Ensure there is only one worksheet.
    Do While objWorkbook.Worksheets.Count > 1
        Set objWorksheet = objWorkbook.Worksheets.Item(objWorkbook.Worksheets.Count)
        objWorksheet.Delete
    Loop
    
    'Set objWorksheet to the remaining worksheet.
    Set objWorksheet = ActiveSheet
    
    any suggestions


Comments

  • Registered Users, Registered Users 2 Posts: 5,741 ✭✭✭jd


    just to be clear-
    you want to opn an excel spreadsheet and edit it?


  • Registered Users, Registered Users 2 Posts: 2,587 ✭✭✭gerire


    What I wanted was to open a specific file, with a specific line design on it, and input info from a list box. I just figured out what to do here's the solving line:
    'Start a workbook.
    Set objWorkbook = objExcel.Workbooks.Open("E:\New Folder (2)\Real\sht1.xls")
    
    instead of .Add


Advertisement