+ Reply to Thread
Results 1 to 13 of 13

No error but no output

Hybrid View

mukeshbaviskar No error but no output 09-11-2013, 09:14 AM
mukeshbaviskar Re: No error but no output 09-11-2013, 10:18 AM
Fotis1991 Re: No error but no output 09-11-2013, 11:57 AM
HaHoBe Re: No error but no output 09-11-2013, 12:03 PM
mukeshbaviskar Re: No error but no output 09-12-2013, 01:19 PM
HaHoBe Re: No error but no output 09-12-2013, 01:34 PM
mukeshbaviskar Re: No error but no output 09-11-2013, 12:29 PM
Fotis1991 Re: No error but no output 09-11-2013, 12:35 PM
mukeshbaviskar Re: No error but no output 09-12-2013, 10:06 PM
HaHoBe Re: No error but no output 09-13-2013, 03:49 AM
mukeshbaviskar Re: No error but no output 09-13-2013, 12:59 PM
HaHoBe Re: No error but no output 09-13-2013, 01:24 PM
mukeshbaviskar Re: No error but no output 09-14-2013, 11:20 AM
  1. #1
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    No error but no output

    Dear Friends,
    In this macro I want to resize picture in same size. The macro is not giving any error but also not giving required output. Please solve my problem. The code is as follows:

    Sub ResizePicing()
        Dim pic As Object, N As String, ws As Worksheet, R As Range, T As Single
         Set ws = ActiveSheet: ws.Range("g:g").ColumnWidth = 15.43: T = 10
        
        For Each pic In ws.Shapes
        If pic.Type = msoPicture Then
            If Abs(pic.Left - Range("g1").Left) < T Then
                        N = pic.Name
            If InStr(1, N, "Butt") Then GoTo GetNext
                pic.LockAspectRatio = msoFalse
                pic.Width = Application.CentimetersToPoints(1.85)
                pic.Height = Application.CentimetersToPoints(2.38)
            
    For Each R In Range("g1:g" & Range("B" & Rows.Count).End(xlUp).Row)
     
        If Abs(pic.Top - R.Top) < T And Abs(pic.Left - R.Left) < T Then
        pic.Left = R.Left: pic.Top = R.Top: R.RowHeight = pic.Height
            Exit For: End If: Next: End If: End If
    GetNext:    Next pic
    End Sub
    Thanking you in anticipation.

    Mukesh
    Last edited by Fotis1991; 09-11-2013 at 11:58 AM. Reason: added code tags..

  2. #2
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: No error but no output

    Sorry Fotis. Now I'm attaching a file here for your kind reference to see where I'm wrong and why the output is not as per my requirement.

    Sorry once again.

    Thanking you in anticipation.

    Mukesh
    Attached Files Attached Files

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: No error but no output

    Mukesh

    I am here for helping people and recently for take care to apply the rules of the forum.

    So I make an effort-last one-for helping you and not punishing you. I'll put code tags in your post. Next time, you have to do yourself or else i'll block your thread.

    I hope someone will be able to help you.

    Good luck.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: No error but no output

    Hi, Mukesh,

    maybe give this macro a run:
    Sub ResizePictures()
    Dim pic As Shape
    Dim ws As Worksheet
    Dim sngT As Single
    
    Set ws = ActiveSheet
    ws.Range("g:g").ColumnWidth = 15.43
    sngT = 10
    
    For Each pic In ws.Shapes
      If pic.Type = msoPicture Then
        With pic
          If Abs(.Left - Range("g1").Left) < sngT Then
            If InStr(1, .Name, "Butt") = 0 Then
              .LockAspectRatio = msoFalse
              .Width = Application.CentimetersToPoints(1.85)
              .Height = Application.CentimetersToPoints(2.38)
              .Left = .TopLeftCell.Left
              .Top = .TopLeftCell.Top
              Rows(.TopLeftCell.Row).RowHeight = .Height
            End If
          End If
        End With
      End If
    Next pic
            
    End Sub
    And maybe resize the pictures and give the rows a different RowHeight before running the code.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  5. #5
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: No error but no output

    Hello HaHoBe,
    Thank you for guidance. It's working fine and my code also work. The problem is that the attached file is not rename the sheet, the photographs ar in sheet1 so the both macros are running without error and giving required output. But in my original file there the sheet is rename as 'Office' and sheet no. is 3.

    I think that because of it the both macros are not giving desire output in my file. Suggestion please.

    Thanking you in anticipation.

    Mukesh

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: No error but no output

    Hi, Mukesh ,

    ActiveSheet will rely on the sheet which is on top in the Application - no matter how that sheet is called or what it´s CodeName is.

    Quote Originally Posted by TO in opening post
    The macro is not giving any error but also not giving required output.
    How should anybody know that you´re talking about your "real" workbook, not the one you attached as sample?

    Quote Originally Posted by TO in Post #7
    ...both macros are running without error and giving required output
    Ciao,
    Holger

  7. #7
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: No error but no output

    Dear Fotis,
    Thank you very much and extremely sorry again. It will not repeat in future.

    Mukesh

  8. #8
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: No error but no output

    Did you see the saggestion in post#4?

  9. #9
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: No error but no output

    Dear Holger,
    Here is a sample file for your reference.

    Thank you.

    Mukesh
    Attached Files Attached Files

  10. #10
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: No error but no output

    Hi, Mukesh,

    when I run the code I get the very same result that you have noticed: no action is taken. Reason for that is that msoPicture is not recognised. If I alter the xlConstant msoPicture to 13 and run the code I get the resize to go:
    Sub ResizePictures()
    Dim pic As Shape
    Dim ws As Worksheet
    Dim sngT As Single
    
    Set ws = ActiveSheet
    ws.Range("g:g").ColumnWidth = 15.43
    sngT = 10
    
    For Each pic In ws.Shapes
      If pic.Type = 13 Then
        With pic
          If Abs(.Left - Range("g1").Left) < sngT Then
            If InStr(1, .Name, "Butt") = 0 Then
              .LockAspectRatio = msoFalse
              .Width = Application.CentimetersToPoints(1.85)
              .Height = Application.CentimetersToPoints(2.38)
              .Left = .TopLeftCell.Left
              .Top = .TopLeftCell.Top
              Rows(.TopLeftCell.Row).RowHeight = .Height
            End If
          End If
        End With
      End If
    Next pic
            
    End Sub
    Ciao,
    Holger

  11. #11
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: No error but no output

    Hi Holger,
    Excellent! But a little problem to solve. After running the macro the picture resize but not align in center. They are left-right-left-right manner. I want to set all the pictures align center. These are the passport size photographs of members. One more thing that I didn't understand that the macro has finish resizing the pictures or not. How much time I have to wait for it. so I want to add a message 'Finished resizing photographs' to start next function.

    Do set the picture align center
    Add a message after finishing the macro mentionned above.

    Just for my information, what the number 13 means in the code?

    Thank you.

    Mukesh

  12. #12
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: No error but no output

    Hi, Mujesh,

    as far as I know there is no command to center a picture in a cell so we need to calculate the width for the cell minus the width of the picture and the divide by 2 and offset that value from the left border of the cell.

    New code:
    Sub ResizePictures_2()
    Dim pic As Shape
    Dim ws As Worksheet
    Dim sngT As Single
    
    Set ws = ActiveSheet
    ws.Range("G:G").ColumnWidth = 15.43
    sngT = 10
    
    For Each pic In ws.Shapes
      If pic.Type = 13 Then
        With pic
          If Abs(.Left - Range("g1").Left) < sngT Then
            If InStr(1, .Name, "Butt") = 0 Then
              .LockAspectRatio = msoFalse
              .Width = Application.CentimetersToPoints(1.85)
              .Height = Application.CentimetersToPoints(2.38)
              .Left = .TopLeftCell.Left + (.TopLeftCell.Offset(0, 1).Left - .TopLeftCell.Left - .Width) / 2
              .Top = .TopLeftCell.Top
              Rows(.TopLeftCell.Row).RowHeight = .Height
            End If
          End If
        End With
      End If
    Next pic
    
    MsgBox "Finished Resize of Pictures", vbInformation, "Resize done"
            
    End Sub
    msoPicture is part of the msoType Collection. All these values all have a Constant as Name as well as a Long as Enumeration, and the numeric value for msoPicture is 13. You might look that up either in the Object Browser (it should be in the MSDN as well). Still I can´t explain why msoPicture doesn´t work when 13 will.

    HTH,
    Holger

  13. #13
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: No error but no output

    Hi Holger,
    Excellent! Now it's working fine and and as per my requirement align center.

    Thank you for solving my problem.

    Mukesh

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Access Query via Excel (ADODB) - no error, but no output!
    By cml111 in forum Access Tables & Databases
    Replies: 3
    Last Post: 04-23-2013, 05:33 AM
  2. [SOLVED] Can I suppress error output?
    By rfcomm2k in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-14-2013, 11:00 AM
  3. Cannot refer to 'error' = #N/A cell output
    By heatwave in forum Excel General
    Replies: 4
    Last Post: 03-09-2011, 11:10 PM
  4. [SOLVED] MATCH output error #N/A
    By RichH in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2005, 02:06 PM
  5. output to error log
    By tubbs in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-06-2005, 06:10 AM

Tags for this Thread

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