+ Reply to Thread
Results 1 to 6 of 6

Image Load Error problem

Hybrid View

homasa Image Load Error problem 12-21-2010, 07:45 AM
royUK Re: Image Load Error problem 12-21-2010, 08:29 AM
homasa Re: Image Load Error problem 12-21-2010, 09:03 AM
homasa Re: Image Load Error problem 12-21-2010, 06:41 PM
royUK Re: Image Load Error problem 12-22-2010, 06:01 AM
homasa Re: Image Load Error problem 12-27-2010, 10:29 AM
  1. #1
    Registered User
    Join Date
    06-25-2010
    Location
    Lisbon
    MS-Off Ver
    Excel 2007
    Posts
    92

    Question Image Load Error problem

    Hello ppl

    i have this script that loads images in the directory but everytime it gives me an error of sharing violation. I attatched an excel file so you can see for yourself.

    I found a solution for this by renaming the file using saveas an then quit, not the correct one i guess but it worked:

    final = picpath & final & "_final.xlsm"
         Application.DisplayAlerts = False
         ActiveWorkbook.SaveAs Filename:=final
         Application.DisplayAlerts = True
         Application.Quit
    My question is when i tryied to changed a bit and
    1) i tryied to "kill the original file" it gives me an error "file allready open"
         final = thisworkbook.name
         inicial = picpath & thisworkbook.name
         final = picpath & final & "_final.xlsm"
         Application.DisplayAlerts = False
         ActiveWorkbook.SaveAs Filename:=final
         ActiveWorkbook.Save
         Kill inicial
         Application.DisplayAlerts = True
         Application.Quit
    2) i tryied to save as final, then original and erase the final it doesn not give me an error but neither saves the images ....
         final = thisworkbook.name
         inicial = picpath & thisworkbook.name
         final = picpath & final & "_final.xlsm"
         Application.DisplayAlerts = False
         ActiveWorkbook.SaveAs Filename:=final
         ActiveWorkbook.Save
         Application.DisplayAlerts = True
         ActiveWorkbook.SaveAs Filename:=inicial
         Kill final
         ActiveWorkbook.Save
    How can i resolve this? how can one saveas 2 times and save the images?
    or am i thinking wrong? is there any other way ?

    by the way i attatched a piece of the file so that you can see for yourself . .

    Thanx in advanced
    Attached Files Attached Files

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Image Load Error problem

    The file to delete needs to be closed.
    final.close
    kill final
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    06-25-2010
    Location
    Lisbon
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: Image Load Error problem

    hello royuk , how are you?

    well, thx for that info but it gives me an error :

    "object required"

    how can i fix this ?

    thx in advanced

  4. #4
    Registered User
    Join Date
    06-25-2010
    Location
    Lisbon
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: Image Load Error problem

    can anyone tell me why this happens ?
    has anyone an solution for this?

    thx in advanced

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Image Load Error problem

    I was only guessing, you don't declare variables in your code. Which workbook do you want to delete?

  6. #6
    Registered User
    Join Date
    06-25-2010
    Location
    Lisbon
    MS-Off Ver
    Excel 2007
    Posts
    92

    Unhappy Re: Image Load Error problem

    hello again, merry christmas

    well,

       Dim objFSO As Object
        Dim objFolder As Object
        Dim objFile As Object
        Dim ws As Worksheet
        Dim picpath As String
        Dim strFile As String
        Dim rngOver As Range
        Dim inicial As String
        Dim final As String
    
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        Set ws = Sheets("Relatório_Sintese")
            picpath = ActiveWorkbook.Path
                If Right(picpath, 1) <> "\" Then
                    picpath = picpath & "\"
                End If
        Set objFolder = objFSO.GetFolder(picpath)
    
    inicial = ThisWorkbook.Name
    If InStr(1, inicial, ".xlsm") Then final = Replace(inicial, ".xlsm", "")
    
         inicial = picpath & ThisWorkbook.Name
         final = picpath & inicial & "_final.xlsm"
         Application.DisplayAlerts = False
         ActiveWorkbook.SaveAs Filename:=final
         Application.DisplayAlerts = True
         ActiveWorkbook.SaveAs Filename:=inicial
         Kill final
         ActiveWorkbook.Save
    how about like this?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1