Note: The other languages of the website are Google-translated. Back to English

Conas íomhá a chóipeáil ón mbileog oibre go dtí an fhoirm úsáideora in Excel?

Taispeánfaidh an t-alt seo modhanna duit chun íomhá a chóipeáil ón mbileog oibre gníomhach go Userform in Excel.

Cóipeáil íomhá ón mbileog oibre go dtí an Fhoirm Úsáideora le cóipeáil agus pasting
Cóipeáil íomhá ón mbileog oibre go dtí an Fhoirm Úsáideora le cód VBA


Cóipeáil íomhá ón mbileog oibre go dtí an Fhoirm Úsáideora le cóipeáil agus pasting

Déan mar a leanas le do thoil chun íomhá a chóipeáil ón mbileog oibre go dtí an Fhoirm Úsáideora.

1. Le haistriú chuig an mbileog oibre tá an íomhá a theastaíonn uait a chóipeáil chuig Userform, agus ansin brúigh an Eile + F11 eochracha le chéile chun an Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

2. Sa Microsoft Visual Basic d’Fheidhmchláir fuinneog, cliceáil le do thoil Ionsáigh > Foirm úsáideora. Féach an pictiúr:

3. Anois cuir Rialú Íomhá isteach sa UserForm. Cliceáil le do thoil ar an Íomha cnaipe sa Bosca uirlisí bosca dialóige, ansin tarraing Rialú Íomhá isteach sa ÚsáideoirForm de láimh. Féach an pictiúr:

4. Cliceáil ar dheis ar an rialú Íomhá a cuireadh isteach, agus cliceáil Airíonna ón roghchlár comhthéacs mar a thaispeántar thíos an scáileán:

5. Ansin is féidir leat a Airíonna taispeántais phána ar thaobh na láimhe clé den Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

6. Téigh ar ais go dtí an bhileog oibre agus roghnaigh an pictiúr a theastaíonn uait a thaispeáint san Fhoirm Úsáideora, agus ansin cóipeáil an pictiúr trí bhrú Ctrl + C eochracha.

7. Téigh isteach sa Microsoft Visual Basic d’Fheidhmchláir arís, scrollaigh síos chun cliceáil ar an Pictiúr réimse agus ansin greamaigh ainm an phictiúir chóipeáilte isteach ann faoin táb Aibítreach.

Anois cóipeáiltear an pictiúr sa bhileog oibre isteach san Fhoirm Úsáideora.


Cóipeáil íomhá ón mbileog oibre go dtí an Fhoirm Úsáideora le cód VBA

Taispeánfaidh an chuid seo beart oibre duit chun iliomad pictiúr a chóipeáil ón mbileog oibre go dtí Foirm Úsáideora, agus ansin an pictiúr comhfhreagrach a thaispeáint san Fhoirm Úsáideora trí ainm an phictiúir a roghnú as bosca Teaglama. Déan mar a leanas le do thoil.

1. Lean céim 1 agus 2 thuas le do thoil o Cuir isteach Foirm Úsáideora i do bhileog oibre.

2. Ansin cuir isteach a Rialú Fráma isteach sa UserFrom mar atá thíos an pictiúr a thaispeántar:

3. Deaschliceáil ar an bhFráma a cuireadh isteach, agus roghnaigh Airíonna ón roghchlár comhthéacs. Ar chlé Airíonna pána, roghnaigh le do thoil Bréagach ó na Infheicthe Gort. Féach an pictiúr:

4. Cuir isteach rialú iolrach Íomhá sa Fhráma mar a thaispeántar thíos.

5. Téigh ar ais go dtí an bhileog oibre agus roghnaigh an pictiúr a theastaíonn uait a thaispeáint san Fhoirm Úsáideora, agus brúigh an Ctrl + C eochracha chun é a chóipeáil.

6. Téigh isteach sa Microsoft Visual Basic d’Fheidhmchláir fuinneog, cliceáil ar dheis ar an gcéad rialú Íomhá, agus roghnaigh Airíonna ón roghchlár cliceáil ar dheis. Féach an pictiúr a thaispeántar.

7. Sa Airíonna phána, cliceáil ar an Pictiúr réimse, ansin brúigh an Ctrl + V eochracha chun an pictiúr a chóipeáil tú i gcéim 5 a ghreamú, agus ansin roghnaigh 1 - fmPictureSizeModeStrtch ó na PictiúrSizeMode liosta anuas mar a thaispeántar thíos an pictiúr.

8. Déan céim 5 - 7 arís chun pictiúir eile a ghreamú ón mbileog oibre go dtí na rialuithe Íomhá ar chlé sa UserForm. Agus taispeánfar an toradh mar a thaispeántar thíos.

9. Bog an Fráma rialú go dtí cúinne an UserForm, ansin cuir isteach ceann nua Íomha rialú agus a Bosca Teaglama rialú isteach sa UserForm. Féach an pictiúr:

10. Deaschliceáil ar an ÚsáideoirForm, Agus ansin cliceáil Féach an cód. Ansin cóipeáil agus greamaigh faoi bhun chód VBA chun an ceann bunaidh a athsholáthar i bhfuinneog an Chóid.

Cód VBA1: Cóipeáil íomhá ón mbileog oibre go dtí an Fhoirm Úsáideora

Private Sub ComboBox1_Change()
    UserForm1.Controls.Item("Image4").Picture = UserForm1.Controls.Item(UserForm1.ComboBox1.Value).Picture
End Sub
Private Sub UserForm_Initialize()
    Dim xImg As Control
    On Error Resume Next
    For Each xImg In UserForm1.Controls
        If TypeName(xImg) = "Image" And xImg.Name <> "Image4" Then
            UserForm1.ComboBox1.AddItem xImg.Name
        End If
    Next
End Sub

Note: In the code, UserForm1 is the name of the inserted UserForm, Image4 is the name of the Image control you will display pictures inside. And Image represents all Image controls which contain the pictures you copied from the worksheet. ComboBox1 is the combobox name you have inserted into the userform. Please change them to your own.

11. Close the Microsoft Visual Basic for Applications window.

12. Insert a Command button into the worksheet by clicking Developer > Insert > Command Button (ActiveX Control).

13. Right-click the command button and select View Code from the Context menu. And then copy and paste the below VBA code into the Code window. And finally close the window.

VBA code2: Copy image from worksheet to Userform

Private Sub CommandButton1_Click()
UserForm1.Show
End Sub

15. Click Developer > Design Mode to turn off the Design Mode.

From now on, when clicking the command button, the UserForm will pop up. You can display picture by selecting the image name from the combo box. See screenshot:

Select different names from the combo box will display different pictures in the UserForm.


Related Articles:


The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office / Excel 2007-2021 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Comments (1)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I'm having difficulties, can someone explain the code for me?
There are no comments posted here yet
Leave your comments
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations

Follow Us

Copyright © 2009 - www.extendoffice.com. | All rights reserved. Powered by ExtendOffice. | Sitemap
Microsoft and the Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.
Protected by Sectigo SSL