Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
dandaanilreddy
Partner - Creator III
Partner - Creator III

Macro not working

hello Developers

I have macros that exports chars to word and excel. 3 Days back it worked fine,but today when i tried the macro is opening excel and word but its exporting script to that word and excel. Any help please.

Thanks

Anil

7 Replies
santiago_respane
Specialist
Specialist

Hi Anil,

please attach macro code or sample app in order to help you finding the solution.

Kind regards,

MK9885
Master II
Master II

Can you post the Macro you using?

dandaanilreddy
Partner - Creator III
Partner - Creator III
Author

Hi

Please see the below script:

Sub Test

Set XWord = CreateObject("Word.Application")

XWord.Visible=true

Set DocWord = XWord.Documents.add()

           With XWord.Selection                     

'.InsertBefore "Titulo"&chr(13)

'.Font.Bold = True

'.Font.Color = RGB(243,58,160)

'.Font.Size = 12

'.Font.Name = "Georgia"

.Collapse wdCollapseEnd

End With

                   

                   

                    ActiveDocument.ClearCache

                    ActiveDocument.GetApplication.WaitForIdle

                  

                    set image = ActiveDocument.GetSheetObject("CH822")

                    image.CopyBitmapToClipboard

                    XWord.Selection.Paste

                   

                    With XWord.Selection

                    XWord.Selection.Collapse wdCollapseEnd

                    XWord.Selection.InsertBefore chr(13)

'                   .InsertBefore "My Chart"&chr(13)

'.Font.Bold = True

'.Font.Color = RGB(243,58,160)

'.Font.Size = 15

'.Font.Name = "Georgia"

.Collapse wdCollapseEnd

end with

                     ActiveDocument.ClearCache

                    ActiveDocument.GetApplication.WaitForIdle    

                 set image = ActiveDocument.GetSheetObject("CH824")

                    image.CopyBitmapToClipboard

                    XWord.Selection.Paste

                   

                     ActiveDocument.ClearCache

                    ActiveDocument.GetApplication.WaitForIdle    

                 set image = ActiveDocument.GetSheetObject("CH827")

                    image.CopyBitmapToClipboard

                    XWord.Selection.Paste

                   

                     ActiveDocument.ClearCache

                    ActiveDocument.GetApplication.WaitForIdle    

                 set image = ActiveDocument.GetSheetObject("CH829")

                    image.CopyBitmapToClipboard

                    XWord.Selection.Paste

                   

                     ActiveDocument.ClearCache

                    ActiveDocument.GetApplication.WaitForIdle    

                 set image = ActiveDocument.GetSheetObject("CH831")

                    image.CopyBitmapToClipboard

                    XWord.Selection.Paste

                   

                     ActiveDocument.ClearCache

                    ActiveDocument.GetApplication.WaitForIdle    

                 set image = ActiveDocument.GetSheetObject("CH832")

                    image.CopyBitmapToClipboard

                    XWord.Selection.Paste

                   

                     ActiveDocument.ClearCache

                    ActiveDocument.GetApplication.WaitForIdle    

                 set image = ActiveDocument.GetSheetObject("CH833")

                    image.CopyBitmapToClipboard

                    XWord.Selection.Paste

            end sub

santiago_respane
Specialist
Specialist

Hi mate,

i've made a little adjust in the macro and it works perfectly in one of my applications, in my case it only exported the two first objects, this is what i did:

  • Changing ids of objects in order for the macro work in my app
  • add this code between every object exported

With XWord.Selection

  .InsertBefore chr(13)

  .Collapse wdCollapseEnd

end with  

Please let me know if this helps.

Kind regards,

dandaanilreddy
Partner - Creator III
Partner - Creator III
Author

Hi Santiago

Thanks for the reply. I am not sure what's happening in my application. It's working now without any change. Do you have any idea why the macro's are not working some time?

Thanks

Anil

santiago_respane
Specialist
Specialist

Hi Anil,

it may depend on a lot of things but when this kind of strange behaviour in QV starts to appear is when i have my pc on for a lot of days wothout any reboot and QV starts acting crazy.

Besides that, without further investigation i dont know what could be the cuase of your issue.

Kind regards,