Excel to Word WholeStory stops macro sometimes..

joyrock37

New Member
Joined
Oct 14, 2011
Messages
26
Hi,
a problem is driving me bonkers :rofl: and I'd love to have help with it!

Task for vba: copy data into a new word document, partially as pictures, partially as tables, so users can edit it.

Code:
Sub ExcelToWord()

Dim wdApp As Object
Dim wdDoc As Object
Set wdApp = CreateObject("Word.Application")
Set wdDoc = wdApp.Documents.Add
wdApp.Visible = True


ThisWorkbook.Sheets("Part 1").Range("A1:S39").Copy
wdApp.Selection.PasteSpecial Link:=False, DataType:=9, _
        Placement:=wdInLine, DisplayAsIcon:=False
wdApp.Selection.Characters.Last.Select

ThisWorkbook.Sheets("Part 2").Range("A1:D43").Copy
wdApp.Selection.PasteSpecial Link:=False, DataType:=10, _
        Placement:=wdInLine, DisplayAsIcon:=False
wdApp.Selection.Characters.Last.Select

ThisWorkbook.Sheets("Part 3").Range("A26:T45").Copy
wdApp.Selection.PasteSpecial Link:=False, DataType:=9, _
        Placement:=wdInLine, DisplayAsIcon:=False
'I added this part below, because text copied from excel appeared as hidden in the word document
'This is also the part where the macro stops sometimes
wdApp.Selection.Wholestory
wdApp.Selection.Font.Hidden = False
wdApp.Selection.Characters.First.Select
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub

There is probably a much better way to write the code, so it is stable and doesn't stop once in a while. Is there a parameter for the pasteSpecial method that makes text not hidden?
Thanks for reading and helping :)
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
maybe Word not visible for help with visible

maybe where your note is use DoEvents and let the system catch itself up, only ideas, no evidence
 
Upvote 0
Hi mole999,
Do you have any idea why Excel doesn't change the property "Wholestory" to "WholeStory"? It seems to work (most of the time) but it's odd.
Thanks for trying :)
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,876
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top