Results 1 to 9 of 9

Thread: Excel - editing

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Location
    NW England
    Posts
    110

    Excel - editing

    What does

    Code:
    MyXL.Workbook(1).Activate
    Do??
    Whhy wont this damn thing work!! Damn it!!!

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    If you have 2 excel files open (workbooks), this code will mimmick the user clicking onto one of the excel workbook windows to select it so as they can start entering values into it's sheets.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Location
    NW England
    Posts
    110
    so in other words....it doesnt solve my problem...dang!!!

    As per another post...my problem is this...

    Code:
    MyXL.application.visible = true 
    MyXL.Windows(1).visible = True
    The above code (plus other bits and pieces i have) opens excel and opens my specified file within it. What i want is for the user to edit the spreadsheet and then save it, however, you cannot edit the spreadsheet at all....you cant even click on another cell...its locked up!!!! You can however, use the excel file menu to close etc etc

    Im wondering if the sheet i open isnt active???


    matt
    Whhy wont this damn thing work!! Damn it!!!

  4. #4
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    I think it's to do with the file itself - outside of the code/vb, can you open up the same Excel file in Excel itself & goto the Tools menu - there's a protection submenu 1/2 way down which should have a "Protect sheet" option there - if you can't see this, but see an "Un-Protect sheet" option, this means someone has added a password to restrict anyone from being able to edit & save the workbook on the actual file itself & I would contact the person who created the file to get them to remove this locking/protection ....

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  5. #5
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Ah, yeah - another thought, there is another way to set protection on an Excel file - if you open the same file up again from within Excel, then goto the Save as menu, you'll see an "advanced" button on the prompting save dialog box which appears, under this button/menu there's a "save options" or "general options" setting/submenu you can click where you can also set this restriction, again, remove this setting & re-save the file ...

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Location
    NW England
    Posts
    110
    Hi

    Its not a protection issue...the excel file was created by me 2 mins before i did the file so theres no protection.

    Also...when a file does have protection, you can normally view it as read only anyway and still edit it but have to save it under a different file name...

    Matt
    Whhy wont this damn thing work!! Damn it!!!

  7. #7
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    As per another post...my problem is this...
    Okay, which one's your other post then, can you post the link for me please?

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  8. #8
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    Code:
    Dim xclObject As New Excel.Application
    Dim xclWorkBook As Excel.Workbook
    Dim xclWorkSheet As Excel.Worksheet
    
    Set xclWorkBook = xclObject.Workbooks.Open("c:\temp.xls")
    Set xclWorkSheet = xclWorkBook.ActiveSheet
        
    xclObject.Application.Visible = True
    xclWorkSheet.Visible = xlSheetVisible

    i did this and it was visible and i could edit it
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  9. #9
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    To do what you're trying, only this is needed really, this will open up an excel file so the users can edit it - if this can't be edited, then it's definitley down to the file itself - maybe the read only flag is ticked on the file right click properties? Or maybe there is a piece of code running on the workbook_activate event which is disabling the editing?
    Code:
    Private Sub Form_Load()
        Dim xclObject As Excel.Application
        Set xclObject = New Excel.Application
        
        With xclObject
            .Workbooks.Open ("c:\temp.xls")
            .Workbooks(1).Worksheets(1).Select
            .Visible = True
        End With
    End Sub

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

Posting Permissions

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



Click Here to Expand Forum to Full Width