Sep 28th, 2004, 10:46 AM
#1
Thread Starter
Hyperactive Member
Word doc
From VB I shell a word doc, for user entry! When they close the doc, is there a way to capture what the user adds to the doc for the database?
Last edited by mudfish; Oct 1st, 2004 at 12:25 PM .
Mudfish AKA Bowfin
I can spell "If" all day right, just a coder!
"Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway
Member of the ECCC
Sep 28th, 2004, 11:05 AM
#2
Frenzied Member
Silly question buy why are you using a Word Doc for user entry? Wouldn't it be easier to create the form in VB and link it to a database?
'Buzby'
Visual Basic Developer
"I'm moving to Theory. Everything works there."
Sep 28th, 2004, 11:09 AM
#3
Thread Starter
Hyperactive Member
Yes it would but the boss would like me to do it like this! I can put data in it, but out I do not know how I would do it! I have also lost control once I shell it!
Mudfish AKA Bowfin
I can spell "If" all day right, just a coder!
"Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway
Member of the ECCC
Sep 28th, 2004, 11:27 AM
#4
Try this for starters.
VB Code:
Option Explicit
'Add a reference to MS Word xx.0 Object Library
Private moApp As Word .Application
Private moDoc As Word .Document
Private Sub cmdOpenDoc_Click()
Set moDoc = moApp.Documents.Open("D:\Development\MyDoc.doc")
End Sub
Private Sub Form_Load()
Set moApp = New Word .Application
moApp.Visible = True
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Sep 28th, 2004, 11:34 AM
#5
Thread Starter
Hyperactive Member
That all most the same code I use to start the doc!
Code:
Call WordMain
LoadDocument "FillText40", strPct_of_Time_Overflow '' pg3 Pct of Time_Overflow
objWord.ActiveDocument.Protect wdAllowOnlyFormFields
objWord.Visible = True
So how can I tell when they close the doc?
Mudfish AKA Bowfin
I can spell "If" all day right, just a coder!
"Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway
Member of the ECCC
Sep 28th, 2004, 11:38 AM
#6
You need to create either a WithEvents event to intercept the
Document_Close event or if you are using the same document all
the time you can add a module and a class module to take full
control of Words events . I have to go to client site right now, but
if no one can help by the time I get back, I will help you more.
Oh ya, search in code bank for my Excel Event demo. Its the basis
for what you want but in Excel.
Later.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Sep 28th, 2004, 12:02 PM
#7
Thread Starter
Hyperactive Member
Thank I found it! I think I will have more ??? so I am not checking the thread off!
Mudfish AKA Bowfin
I can spell "If" all day right, just a coder!
"Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway
Member of the ECCC
Sep 28th, 2004, 01:46 PM
#8
Thread Starter
Hyperactive Member
RobDog888
This code would go in excel?
"
Option Explicit
Private RD As clsMyEvents
"
I am using a .dot for this project!
Mudfish AKA Bowfin
I can spell "If" all day right, just a coder!
"Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway
Member of the ECCC
Sep 28th, 2004, 02:38 PM
#9
No, the logic is what you want to replicate in Word . I just got
back from the Clients site and I am going to lunch. Be back with
an example after lunch.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Sep 28th, 2004, 02:49 PM
#10
Thread Starter
Hyperactive Member
I am east coast!
It is near quitting time here.
Will a macro have to go into my system?
Thank for the help!
Mudfish AKA Bowfin
I can spell "If" all day right, just a coder!
"Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway
Member of the ECCC
Sep 28th, 2004, 03:20 PM
#11
I got the demo attached for you, but because of the immediatness
of the request, I only had time to do it in Word . If you need to
use VB to simulate the same thing let me know.
VB Code:
'ThisDocument
Option Explicit
Private RD As clsMyEvents
Private Sub Document_Open()
Set RD = New clsMyEvents
MsgBox "My Events Created!", vbOKOnly + vbInformation, "My Word Events "
End Sub
'Name: clsMyEvents
'Instancing: Private
Option Explicit
Public goWord As Word .Application
Public WithEvents MyEventsDoc As Word .Document
Public WithEvents MyEventsApp As Word .Application
Private Sub Class_Initialize()
Set goWord = GetObject(, "Word .Application")
Set MyEventsDoc = ThisDocument
Set MyEventsApp = goWord
End Sub
Private Sub Class_Terminate()
Set goWord = Nothing
End Sub
Private Sub MyEventsApp_DocumentBeforeClose(ByVal Doc As Document, Cancel As Boolean)
Dim iResp As Integer
iResp = MsgBox("RobDog888: Do you want to save your document?", vbYesNoCancel + vbQuestion, "My Word Events ")
If iResp = vbYes Then
goWord.ActiveDocument.Save
If goWord.ActiveDocument.Saved = True Then
MsgBox "Saved!", vbOKOnly + vbInformation, "My Word Events "
Else
MsgBox "Error Saving Document!" & vbNewLine & "Sorry!", vbOKOnly + vbCritical, "My Word Events "
End If
ElseIf iResp = vbCancel Then
Cancel = True
End If
End Sub
VB/Outlook Guru!
Attached Files
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Sep 28th, 2004, 04:53 PM
#12
Thread Starter
Hyperactive Member
At home, had to see the code!
Take some time!
My work day was over.
I am not set up at home to run what I was working on.
Thank for the help!
PS We run preloaded machines and push code down our lines!
That why I ask for about a macro!
Mudfish AKA Bowfin
I can spell "If" all day right, just a coder!
"Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway
Member of the ECCC
Sep 29th, 2004, 06:30 AM
#13
Thread Starter
Hyperactive Member
Fire wall will not let me download!
I am working in VB 6.5!
This code is on a form?
"
'ThisDocument
Option Explicit
Private RD As clsMyEvents
Private Sub Document_Open()
Set RD = New clsMyEvents
MsgBox "My Events Created!", vbOKOnly + vbInformation, "My Word Events "
End Sub
"
Should have got the download from the house!
Compile error
User-defined type not defined
On
Private RD As clsMyEvents
I have the word reference in the project
Last edited by mudfish; Sep 29th, 2004 at 07:16 AM .
Mudfish AKA Bowfin
I can spell "If" all day right, just a coder!
"Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway
Member of the ECCC
Sep 29th, 2004, 12:51 PM
#14
Its behind the word document (VBA).
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Sep 29th, 2004, 12:55 PM
#15
Thread Starter
Hyperactive Member
Can I get this to work out of VB to a .dot?
Mudfish AKA Bowfin
I can spell "If" all day right, just a coder!
"Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway
Member of the ECCC
Sep 29th, 2004, 08:49 PM
#16
What is the way you hope to have this working?
[list=1][*]From VB only[*]From Word only[*]From VB and Word Template[/list=1]
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Sep 30th, 2004, 06:38 AM
#17
Thread Starter
Hyperactive Member
Originally posted by RobDog888
What is the way you hope to have this working?
From VB and Word Template
I have a VB form that I am filling a listbox with name from the database. User picks a name and I fill the dot with data from the database and shell the dot. The user can fill in some fields in the dot and print it. They want me to be able to shell it blank, let user fill in and save it back to the database. I am working on doing it in VBA. We have a large area network that our machines are preloaded with the VB package, so we can just transmit code down our lines. So if I add code to the dot I can just transmit it down the line with the code.
This should work; the code in VBA is attached to the dot, right?
I have your word doc got to the code change it some, but I do not see the changes on the word doc. How do I compile in VBA?
Last edited by mudfish; Sep 30th, 2004 at 08:11 AM .
Mudfish AKA Bowfin
I can spell "If" all day right, just a coder!
"Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway
Member of the ECCC
Sep 30th, 2004, 12:32 PM
#18
I think the only version of Office VBA that had a compiler was
Office XP Developer. I always had problems creating and trapping
events in Word from VB, but I can give it another try later today.
One of the problems was when the user had more than one
instance of wrod running.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Sep 30th, 2004, 04:52 PM
#19
Thread Starter
Hyperactive Member
Yes I can see that been a problem.
They have pull me off for right now, but there is always tomorrow!
Thanks for the input!
I got in your code on the word doc and change the message, but I do not see it changing.
I see a huge script in it also.
Mudfish AKA Bowfin
I can spell "If" all day right, just a coder!
"Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway
Member of the ECCC
Sep 30th, 2004, 05:01 PM
#20
Did you try the document attachment in my post that shows the code?
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Sep 30th, 2004, 07:45 PM
#21
Thread Starter
Hyperactive Member
Yes I got in your code on the word doc and change the closing message, but I do not see the message changing when I would close the doc?
I also see a huge VS script in the word doc also.
Thanks again
Mudfish AKA Bowfin
I can spell "If" all day right, just a coder!
"Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway
Member of the ECCC
Sep 30th, 2004, 07:50 PM
#22
You changed the message in this line?
VB Code:
iResp = MsgBox("RobDog888: Do you want to save your document?", vbYesNoCancel + vbQuestion, "My Word Events ")
You shouldnt see any more code in the word doc module (ThisDocument)
and class file (clsMyEvents) than what I posted earlier.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Sep 30th, 2004, 07:56 PM
#23
Thread Starter
Hyperactive Member
Mudfish AKA Bowfin
I can spell "If" all day right, just a coder!
"Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway
Member of the ECCC
Sep 30th, 2004, 07:59 PM
#24
You close the document and save the changes? Then when you
open the document, the welcome message is still the same or
when you close the document at this point still should the original message?
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Sep 30th, 2004, 08:02 PM
#25
Thread Starter
Hyperactive Member
I was looking for it at close.
When I try and run it in the VBA like I would in VB it wants me to name and create a macro, I think! It is not in front of me, at home!
I have 6.5 VB, C++ 6 XP office Pro and .Net studio.
Last edited by mudfish; Sep 30th, 2004 at 08:23 PM .
Mudfish AKA Bowfin
I can spell "If" all day right, just a coder!
"Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway
Member of the ECCC
Sep 30th, 2004, 08:25 PM
#26
Does the code reflect the change the next time you open the doc?
Maybe it was stuck in memory or the vba code was in run mode?
What is the cange you want in the close message?
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Sep 30th, 2004, 08:31 PM
#27
Thread Starter
Hyperactive Member
I add some number to "45456RobDog888: Do you want to save your document".
But I am only getting "Do you want to save your document".
I wish I had it here, I also have SQL enterprise manager, XP network and Multi-edit.
Mudfish AKA Bowfin
I can spell "If" all day right, just a coder!
"Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway
Member of the ECCC
Sep 30th, 2004, 08:34 PM
#28
Ah! I think its not running the custome msgbox. If the title of the
close msgbox does not say "My Word Events " then it is the Word
msgbox and not ours firing.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Sep 30th, 2004, 08:38 PM
#29
Thread Starter
Hyperactive Member
It like this "MyWordEvents", like the doc name!
Mudfish AKA Bowfin
I can spell "If" all day right, just a coder!
"Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway
Member of the ECCC
Sep 30th, 2004, 08:44 PM
#30
Oh ya, check to make sure that you have Macros enabled when
word starts. Set the marco security to medium so you can choose
the setting each time Word starts. I get the feeling that its not
runing.
Edit: the save msgbox title should be exactly - "My Word Events "
if its running. Not the document name.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Sep 30th, 2004, 08:52 PM
#31
Thread Starter
Hyperactive Member
It late here 5:30 come fast.
I try at work.
Thanks.
Mudfish AKA Bowfin
I can spell "If" all day right, just a coder!
"Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway
Member of the ECCC
Sep 30th, 2004, 08:57 PM
#32
Ok, see you tomorrow. Its 7:00 pm here.
Later
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Oct 1st, 2004, 06:35 AM
#33
Thread Starter
Hyperactive Member
Oct 1st, 2004, 11:02 AM
#34
You say you still get the Word save message meaning that
you are not getting the custom save message?
You mean that you want the project to be in Words VBA and you
want to know if you can use SQL in there then the answer is yes,
I think so. I havent tried it but it should be possible.
Let me know.
Its 9:00 am over here now. I just got in.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Oct 1st, 2004, 11:12 AM
#35
Thread Starter
Hyperactive Member
Originally posted by RobDog888
You say you still get the Word save message meaning that
you are not getting the custom save message?
I am get 2 custom and 1 word message! If I do not save.
If I save I get 3 custom.
So you think ADO will work?
Last edited by mudfish; Oct 1st, 2004 at 11:27 AM .
Mudfish AKA Bowfin
I can spell "If" all day right, just a coder!
"Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway
Member of the ECCC
Oct 1st, 2004, 11:59 AM
#36
I just had to see if I could make you a example using ADO and SQL.
So here it is.
Note this is separate from the other document and not inclusive
of what we have done earlier.
VB Code:
Option Explicit
'RobDog888 10/01/2004
'ThisDocument
'Add reference to MS ActiveX Data Objects 2.x Library
'Tools > References ...
Private Sub Document_Open()
'Initialize SQL connection and objects
Main
Stop
'Command1_Click
End Sub
Private Sub Command1_Click()
On Error GoTo No_Bugs
Dim oRs As ADODB.Recordset
Set oRs = New ADODB.Recordset
Set oRs = goEnv.SQLTie.QrySQLTable("FindMe")
If oRs.BOF = False And oRs.EOF = False Then
'Do something with the recordset
Do While oRs.EOF = False
'...
'...
'...
oRs.MoveNext
Loop
Else
MsgBox "No Records Returned!", vbOKOnly + vbExclamation, "RobDog888 - Command1_Click"
End If
If oRs.State = adStateOpen Then oRs.Close
Set oRs = Nothing
Exit Sub
No_Bugs:
MsgBox Err.Number & " - " & Err.Description, vbOKOnly + vbExclamation, "RobDog999 - Command1_Click"
End Sub
'********************************************************************************************************
Option Explicit
'RobDog888 10/01/2004
'Module: modMain
Public goEnv As clsEnv
Public Sub Main()
Set goEnv = New clsEnv
'Change the server and database names to yours
If goEnv.DBConnect("\\ServerName\DatabaseName") = False Then
MsgBox "Failed to connect to database!" & vbNewLine & _
"Please contact an Administrator to check if you have the appropriate permissions.", _
vbExclamation + vbOKOnly, "RobDog888 - Main"
Set goEnv = Nothing
Else
MsgBox "Connected to SQL Database!", vbOKOnly + vbInformation, "RobDog888 - Main"
End If
End Sub
'********************************************************************************************************
Option Explicit
'RobDog888 10/01/2004
'Class: clsEnv
'Instancing: Private
Private moCnn As ADODB.Connection
Private moSQLTie As clsSQL
Public Property Get Cnn() As ADODB.Connection
Set Cnn = moCnn
End Property
Public Property Get SQLTie() As clsSQL
Set SQLTie = moSQLTie
End Property
Public Function DBConnect(ByVal sDBPath As String) As Boolean
On Error GoTo No_Bugs
Dim sDB As String
Dim sSQL As String
sDB = InStrRev(sDBPath, "\")
sSQL = Mid(sDBPath, 1, sDB - 1)
sDB = Mid(sDBPath, sDB + 1)
sSQL = Mid(sSQL, 3)
If moCnn.State = adStateClosed Then
moCnn.ConnectionString = "provider=sqloledb;data source=" & sSQL & ";initial catalog=" & sDB & _
";integrated security=sspi;"
'Add "integrated security=sspi"
moCnn.Open
DBConnect = True
Else
moCnn.Close
moCnn.ConnectionString = "provider=sqloledb;data source=" & sSQL & ";initial catalog=" & sDB & _
";integrated security=sspi;"
moCnn.Open
DBConnect = True
End If
Exit Function
No_Bugs:
If Err.Number = "-2147467259" Then
MsgBox "Error connecting to database!", vbOKOnly + vbCritical, "RobDog888 - DBConnect"
Else
MsgBox Err.Number & " - " & Err.Description, vbOKOnly + vbInformation, "RobDog888 - DBConnect"
End If
DBConnect = False
Exit Function
Resume
End Function
Private Sub Class_Initialize()
Set moCnn = New ADODB.Connection
Set moSQLTie = New clsSQL
End Sub
Private Sub Class_Terminate()
Set moCnn = Nothing
Set moSQLTie = Nothing
End Sub
'********************************************************************************************************
Option Explicit
'RobDog888 10/01/2004
'Class: clsSQL
'Instancing: Private
Public Function QrySQLTable(ByVal sAction As String) As ADODB.Recordset
On Error GoTo No_Bugs
Dim oRs As New ADODB.Recordset
Dim sSQL As String
sSQL = "SELECT"
sSQL = sSQL & " Field1,"
sSQL = sSQL & " Field2,"
sSQL = sSQL & " Field3"
sSQL = sSQL & " FROM"
sSQL = sSQL & " Table1"
sSQL = sSQL & " WHERE"
sSQL = sSQL & " Field1 = '" & sAction & "'"
Set oRs = New ADODB.Recordset
oRs.Open sSQL, goEnv.Cnn, adOpenKeyset, adLockOptimistic, adCmdText
Set QrySQLTable = oRs
Set oRs = Nothing
Exit Function
No_Bugs:
MsgBox Err.Number & " - " & Err.Description, vbOKOnly + vbInformation, "RobDog888 - QrySQLTable"
End Function
VB/Outlook Guru!
Attached Files
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Oct 1st, 2004, 12:25 PM
#37
Thread Starter
Hyperactive Member
Great!
Soon as I am allowed to work on the program again, I will try it!
Thanks again.
Mudfish AKA Bowfin
I can spell "If" all day right, just a coder!
"Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway
Member of the ECCC
Oct 1st, 2004, 01:43 PM
#38
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width