Results 1 to 7 of 7
  1. #1
    stingray is offline Novice
    Windows 11 Office 365
    Join Date
    Jan 2025
    Posts
    22

    How to show an image in a report, but rotate at 90 degrees to the right

    Hello. I was able to complete my first task on Access with your help. When I show it to the user today, I was asked to come up with another report with a barcode image rotated at 90 degrees to the right.
    The barcode images are stored in the DB, in a table as attachments. Google told me that it is very difficult to do this with VBA, and I found something that they do, but I need to save the image file.
    https://www.devhut.net/vba-wia-rotate-an-image/

    Each barcode is about 5KB, very small, and eventually I may have 300 records. That is 1.5MB. Maybe I need to find a way to temporarily store the rotated image file, and drop it each time. If there is better way, please help me.

  2. #2
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    you need WIA automation to rotate the image and
    use the rotated image as controlsource of your image control.
    see report, sampleReport.
    see the code on Module1.
    Attached Files Attached Files

  3. #3
    Edgar is offline Competent Performer
    Windows 8 Access 2016
    Join Date
    Dec 2022
    Posts
    309
    WIA rotation can be done like this
    Code:
    Sub RotateImage(inputPath As String, outputPath As String, angle As Long)
        With CreateObject("WIA.ImageProcess")
            Dim img As Object
            Set img = CreateObject("WIA.ImageFile")
            img.LoadFile inputPath
        
            .Filters.Add .FilterInfos("RotateFlip").FilterID
            .Filters(1).Properties("RotationAngle") = angle
            Set img = .Apply(img)
    
            img.SaveFile outputPath
            
        End With
    End Sub
    You basically process the image by adding filters to the filters collection and then you apply them.

    Check out: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/wiaaut/-wiaaut-howto-use-filters#rotateflip-filter-rotate-a-picture

    WIA is limited, but it gets the job done.

    If you want to have more image capabilities, there are some nice utilities out there, like ImageMagick. To use that, you could do this AFTER INSTALLING IT:
    Code:
    Sub RotateImage(inputPath As String, outputPath As String, angle As Long)
        Dim magick As String
        magick = CreateObject("WScript.Shell").Exec("cmd /c where magick").StdOut.ReadLine
        Shell magick & " " & inputPath & " -rotate 90 " & outputPath
    End Sub
    It's fewer lines of code and it has way more features. Check it out here: https://imagemagick.org/index.php

    You asked for rotation for a report and jojowhite made a nice database for that.

    I have a little sample that does the image rotation in real time in forms, not in reports, just in case some passerby wants to check it out as well. It uses the browser control.
    Attached Files Attached Files
    Please click on the ⭐ below if this post helped you.


  4. #4
    stingray is offline Novice
    Windows 11 Office 365
    Join Date
    Jan 2025
    Posts
    22
    Hi, Edgar.
    This is great information, and it is free. Thank you!
    Right now I am struggling with integrating, to extract a picture from the DB and get the path.

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Quote Originally Posted by stingray View Post
    Hi, Edgar.
    This is great information, and it is free. Thank you!
    Right now I am struggling with integrating, to extract a picture from the DB and get the path.
    Always my first point of call https://www.google.com/search?q=save...hrome&ie=UTF-8
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    stingray is offline Novice
    Windows 11 Office 365
    Join Date
    Jan 2025
    Posts
    22
    Quote Originally Posted by jojowhite View Post
    you need WIA automation to rotate the image and
    use the rotated image as controlsource of your image control.
    see report, sampleReport.
    see the code on Module1.
    Thank you so much for the sample. I can see how things are done. I want to use CustomerSKU to filter (I just need to print one record at a time), and I am really having a hard time now. I just wanted to tell you that I am working on it, and am very grateful!

  7. #7
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    you can always upload a sample of your db if you got stuck.

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

Similar Threads

  1. Replies: 4
    Last Post: 12-15-2022, 05:56 AM
  2. Replies: 6
    Last Post: 09-18-2020, 09:06 PM
  3. Replies: 3
    Last Post: 08-09-2020, 08:09 PM
  4. Replies: 5
    Last Post: 07-10-2020, 12:41 PM
  5. Rotate Report 90 Degrees
    By Bella's Mom in forum Reports
    Replies: 2
    Last Post: 08-14-2015, 10:43 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