Home > Software engineering >  Why can't this command output to Excel within a column cell into a content images
Why can't this command output to Excel within a column cell into a content images

Time:06-05

Sub exportPic ()
For K=1 To Cells (Rows) Count, 1.) the End (xlUp). Row
Sheets (1) Cells (K, 1) CopyPicture
Set CHT=ActiveSheet. ChartObjects. Add (0, 0, Cells (K, 1). The Width of Cells (K, 1). The Height). The Chart
With CHT
The Paste
"D: ".export & amp; Cells (K, 1) & amp; ". JPG "
. The Parent. Delete
End With
Next K
The set CHT=NOTHING
End Sub


Use this code output images is blank, no text within the cell

CodePudding user response:

Excel there is no such function, not to save what can save

CodePudding user response:

Images are images, words are words, excel it looks in the picture has a word is also the result of the text superimposed on the image display, your order is just to save the pictures,
If you want to put text output to the Picture, you must use a Picture object to process the image, printed text will save later on,

CodePudding user response:

One to the graduation season, this kind of no practical use of functional requirements problems come,
Think, middle school teachers doesn't matter, engineering college teachers should have at least three years working experience in enterprise to coach,

CodePudding user response:

Paste after add DoEvents:
 
Sub exportPic ()
Dim K As Long
For K=1 To Cells (Rows) Count, 1.) the End (xlUp). Row
Sheets (1) Cells (K, 1) CopyPicture
Dim CHT As Chart
Set CHT=ActiveSheet. ChartObjects. Add (0, 0, Cells (K, 1). The Width of Cells (K, 1). The Height). The Chart
With CHT
The Paste
DoEvents
"D: ".export & amp; Cells (K, 1) & amp; ". JPG "
. The Parent. Delete
End With
Next K
The Set CHT=Nothing
End Sub

Run the example:

CodePudding user response:

reference 4 floor milaoshu1020 response:
paste after add DoEvents:
 
Sub exportPic ()
Dim K As Long
For K=1 To Cells (Rows) Count, 1.) the End (xlUp). Row
Sheets (1) Cells (K, 1) CopyPicture
Dim CHT As Chart
Set CHT=ActiveSheet. ChartObjects. Add (0, 0, Cells (K, 1). The Width of Cells (K, 1). The Height). The Chart
With CHT
The Paste
DoEvents
"D: ".export & amp; Cells (K, 1) & amp; ". JPG "
. The Parent. Delete
End With
Next K
The Set CHT=Nothing
End Sub

Run the example:
learn new knowledge, although there are no dice, but who is the thin hair at ordinary times in the key,
  •  Tags:  
  • VBA
  • Related