2017-12-06 3 views
0

내 프로그램 :ms 단어로 사진을 확대하고 넓히는 방법?

엑셀에서 데이터를 추출하는 그림을 만듭니다.

단어로 붙여넣고 페이지 설정을 가로로 설정하십시오.

그러나 생성 된 그림은 작고 페이지 설정은 사용자 지정이됩니다.

사진의 너비가 너무 큽니다. 매회 나 혼자서 확대하고 싶지 않습니다.

vba에서이 설정을 어떻게 추가 할 수 있습니까? 가능한 한 크게 확대하십시오.

두 번째로, 추출 된 데이터를 표 형식으로 붙여 넣을 수있어서 기쁩니다.

내 코드 : 제가 말씀하지만, 엑셀 바이올린 없지만

Private Sub CommandButton1_Click() 

    Dim tbl0 As Excel.RANGE 
    Dim Tbl As Excel.RANGE 
    Dim tbl2 As Excel.RANGE 

    Dim wordApp As Word.Application 
    Dim myDoc As Word.Document 
    Dim WordTable As Word.Table 
    Dim wb As Workbook 
    Dim ws As Worksheet 

    Set wb = ThisWorkbook 
    Set ws = wb.Worksheets("17-18")    ' Change e.g. sheet9.Name 
    'Optimize Code 
    Application.ScreenUpdating = False 
    Application.EnableEvents = False 

Value1 = Me.TextBox1.Value 
Value2 = Me.TextBox2.Value 
    ws.Rows("84:89").EntireRow.Hidden = True 'ADJUST AS APPROPRIATE 

    'Copy Range from Excel 
    'Set tbl0 = ws.RANGE("A78:I83") 
    Set Tbl = ws.RANGE("A78:I92") 


    ' Set tbl2 = ws.Range("A90:I92") 

    'Create an Instance of MS Word 
    On Error Resume Next 

    'Is MS Word already opened? 
    Set wordApp = GetObject(Class:="Word.Application") 

    'Clear the error between errors 
    Err.Clear 

    'If MS Word is not already open then open MS Word 
    If wordApp Is Nothing Then Set wordApp = CreateObject(Class:="Word.Application") 

    'Handle if the Word Application is not found 
    If Err.Number = 429 Then 
     MsgBox "Microsoft Word could not be found, aborting." 
     GoTo EndRoutine 
    End If 

    On Error GoTo 0 

    'Make MS Word Visible and Active 
    wordApp.Visible = True 
    wordApp.Activate 

    'Create a New Document 
    Set myDoc = wordApp.Documents.Add 

    'Trigger copy separately for each table + paste for each table 

    Tbl.CopyPicture Appearance:=xlScreen, Format:=xlPicture 

    wordApp.Selection.Paste 
    wordApp.Selection.TypeParagraph 

    wordApp.Selection.PageSetup.Orientation = wdOrientLandscape 

    resize_all_images_to_page_width myDoc 

EndRoutine: 
    'Optimize Code 
    Application.ScreenUpdating = True 
    Application.EnableEvents = True 

    'Clear The Clipboard 
    Application.CutCopyMode = False 

End Sub 

답변

0

만 그것은 당신에게 아이디어를 줄 수 ...

내 XmasPrep 엑셀의 코드는 사진의 무리에 짜증 카탈로그를 제작하려면 선택할 사진을 나열하십시오. 각 라인

enter image description here

즉, 각 픽처,

  • 후 엑셀 셀 범위를 할당하고, 코드 범위 ROW 높이와 폭 뿐만 아니라 다양한 높이 자체
  • 크기를 조절

    은 그림 개체 thisPic = .Parent.Pictures.Insert (picFileName)를 할당 한 다음 셀 범위의 좌표 및 크기에 따라 크기를 조정합니다.

    thisPic.Top = .Top + 1 
    thisPic.Left = .Left + 1 
    thisPic.Width = .Width - 2 
    thisPic.Height = .Height - 2 
    

Word에서 그림 개체 (thisPic)를 잡을 수 있다면 필요에 맞게 크기를 조정할 수 있습니다. 희망이 도움이됩니다.

: 
    Const MaxHeight = 50 
    Const MaxWidth = 14 
    Dim picFileName   As String 
    Dim i, j, k    As Long 
    Dim col_Filenames  As Long 
    Dim col_Pictures  As Long 
    Dim range_PicCell  As Range 
    Dim thisPic    As Picture 
    : 

    picFileName = filesPath & select2order.Cells(i, col_Filenames).Value 
    Set range_PicCell = select2order.Cells(i, col_Pictures) 
    range_PicCell.RowHeight = MaxHeight 
    range_PicCell.ColumnWidth = MaxWidth 
    With range_PicCell 
     .Height = MaxHeight 
     Set thisPic = .Parent.Pictures.Insert(picFileName) 
     thisPic.Top = .Top + 1 
     thisPic.Left = .Left + 1 
     thisPic.Width = .Width - 2 
     thisPic.Height = .Height - 2 
    End With 
    : 
+0

멋진 답변이지만, 사진을 Word로 복사하고 있습니다. – Vityata

+0

예, 참. 그러나 코드가 붙여 넣기 후 그림 개체를 움켜 잡고 단어의 프레임 크기를 알 수 있다면 ... –

+0

또는 Excel에서 표 형식으로 표를 추출하고 Word 문서의 크기에 가장 적합하게 맞 춥니 다? – Vito