Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 11-30-2011, 04:28 AM
macropod's Avatar
macropod macropod is offline Why it works but the macro is error in VB? Windows 7 64bit Why it works but the macro is error in VB? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Tinfanide,

The error is probably because you're not telling the calling App that it's AppWord's ActiveDocument you want to save. Try something along the lines of:
Code:
Private Sub copytoWord_Click()
Sheets("Sheet1").Range("A1:B4").Copy
Dim AppWord As Word.Application
Set AppWord = CreateObject("Word.Application")
With AppWord
  .Visible = True
  .Documents.Add
  .Selection.Paste
  .CutCopyMode = False
  .ActiveDocument.SaveAs2 "C:\Users\Tin\Desktop\" & "Book1", wdFormatDocumentDefault
  .Quit
End With
Set AppWord = Nothing
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple VBA macro error Formulayeti PowerPoint 1 12-09-2011 10:02 PM
Why it works but the macro is error in VB? Runtime Error 4120 in Word 2007 macro Frankwlc Word 5 11-28-2011 01:54 AM
Why it works but the macro is error in VB? Works to word Janette Word 1 11-12-2011 08:23 AM
Macro Error 5174 muster36 Word VBA 0 08-12-2011 03:34 AM
Converting from Works Menno Hershberger Office 0 09-01-2010 11:33 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:34 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft