Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word VBA

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 03-09-2019, 11:03 PM
matapagi2019 matapagi2019 is offline Windows XP Office 2007
Novice
 
Join Date: Mar 2019
Posts: 8
matapagi2019 is on a distinguished road
Default Open word userform from excel


I want the button on userformTombol in document "Agendaku.docm" activate after The Excel application Quit.
What is the mistakes in the following code: ? (error message : Object dosn't support this property or method)
Code:
Private Sub CommandButton1_Click()Dim ObjWord As Object
Dim ObjDoc As Object
Dim ObjForm As Object
    Set ObjWord = GetObject(, "Word.Application")
    Set ObjDoc = ObjWord.Documents("D:\Agendaku.docm")
    ObjWord.Visible = True
    Set ObjForm = ObjWord.ObjDoc.UserFormTombol
        ObjForm.CommandButton1.Enabled = True
        ObjForm.CommandButton3.Enabled = False
    ActiveWorkbook.Save
    Windows.Application.Quit
End Sub
Thank you all !
Reply With Quote
  #2  
Old 03-10-2019, 01:13 AM
macropod's Avatar
macropod macropod is online now Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,098
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Cross-posted at: https://www.mrexcel.com/forum/genera...orm-excel.html
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 03-10-2019, 03:06 AM
Guessed's Avatar
Guessed Guessed is online now Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 1,080
Guessed has a spectacular aura aboutGuessed has a spectacular aura aboutGuessed has a spectacular aura about
Default

You are using GetObject which means Word must already be running. If it isn't then you need to use CreateObject.

Assuming that works, then Agendaku.docm must already be open. If it isn't then that will fail too.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #4  
Old 03-10-2019, 03:25 AM
matapagi2019 matapagi2019 is offline Windows XP Office 2007
Novice
 
Join Date: Mar 2019
Posts: 8
matapagi2019 is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
You are using GetObject which means Word must already be running. If it isn't then you need to use CreateObject.

Assuming that works, then Agendaku.docm must already be open. If it isn't then that will fail too.
Yes, it is.
Agendaku.docm is already open.

But why does the error message still appear ?
Reply With Quote
  #5  
Old 03-11-2019, 02:21 PM
Guessed's Avatar
Guessed Guessed is online now Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 1,080
Guessed has a spectacular aura aboutGuessed has a spectacular aura aboutGuessed has a spectacular aura about
Default

You haven't told us which line is failing.

Assuming the Agendaku.docm file does indeed contain a userform with the name UserFormTombol, I would have expected you would need to LOAD that userform before trying to set the enabled values of controls in it. I also don't know if those two controls exist on your userform.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word VBA: Open and work with a different doc from userform? AlanC Word VBA 2 06-25-2018 06:58 AM
Word UserForm search in Excel jhancock1994 Word VBA 3 05-21-2017 11:51 PM
Excel Userform to Word Template Bookmarks JCrinage Excel Programming 1 11-02-2016 07:03 PM
Populate Combobox from Excel into a Word UserForm ferguson4848 Word VBA 3 10-28-2016 09:05 PM
Trying to populate Word bookmarks with excel UserForm smd1112 Excel Programming 7 09-03-2014 09:42 PM


All times are GMT -7. The time now is 04:00 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft