473,387 Members | 3,684 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Can't use Dialogs.Item(wdDialogFileOpen)

I am not able to use Dialogs.Item(wdDialogFileOpen) because of the way I'm using word inside of another application. The code below works outside of the application but not in it:

Expand|Select|Wrap|Line Numbers
  1. Sub FileInsert()
  2.  
  3. ChangeFileOpenDirectory _
  4.     "F:\Some\Folder\OnThe\Network"
  5.  
  6. With Dialogs.Item(wdDialogFileOpen)
  7.     .Name = "*.doc"
  8. If .Display = -1 Then
  9.     Selection.InsertFile FileName:=.Name, Range:="", _
  10.         ConfirmConversions:=False, Link:=False, Attachment:=False
  11.  
  12. End If
  13. End With
  14.  
  15. End Sub
I'm looking to see if there is another method to do the same thing but not using the Dialogs command. The InsertFile command still works in the application but you have to choose a file to insert. I want to select the file. Any thoughts or am I SOL.....

Thanks
Jan 23 '08 #1
2 2278
kadghar
1,295 Expert 1GB
I am not able to use Dialogs.Item(wdDialogFileOpen) because of the way I'm using word inside of another application. The code below works outside of the application but not in it:

Sub FileInsert()

ChangeFileOpenDirectory _
"F:\Some\Folder\OnThe\Network"

With Dialogs.Item(wdDialogFileOpen)
.Name = "*.doc"
If .Display = -1 Then
Selection.InsertFile FileName:=.Name, Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False

End If
End With

End Sub

I'm looking to see if there is another method to do the same thing but not using the Dialogs command. The InsertFile command still works in the application but you have to choose a file to insert. I want to select the file. Any thoughts or am I SOL.....

Thanks
you can always "cheat" a little bit:
create an object, open an Word Application in it, and use its dialogs ;)

Expand|Select|Wrap|Line Numbers
  1. dim obj1 as object
  2. set obj1 = createobject("word.application")
  3. With obj1.Dialogs.Item(80)  'dont use word constants outside word, check what's its numeric value.
  4.     .Name = "*.doc"
  5. If .Display = -1 Then
  6.    Selection.InsertFile FileName:=.Name, Range:="", _
  7.         ConfirmConversions:=False, Link:=False, Attachment:=False
  8. End If
  9. End With
that should help the Dialogs thing... now, i dont know what's that "selection.insertfile" for, that might cause you further problems. Give it a check.

HTH
Jan 23 '08 #2
Hi HTH,

Thank you for your help. That worked. The insert file command is so we can put the body of a document into another document, its used for transcription in this case.

I made a few changes to perfect it. Below is the code that I'm using:

Sub InsertFile()

ChangeFileOpenDirectory _
"F:\Some\Folder\On The\Network"

Dim obj1 As Object
Set obj1 = CreateObject("word.application")
obj1.ChangeFileOpenDirectory _
"F:\Some\Folder\On The\Network"
With obj1.Dialogs.Item(80) 'dont use word constants outside word, check what's its numeric value.
.Name = "*.doc"
If .Display = -1 Then
Selection.InsertFile FileName:=.Name, Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
End If
End With
obj1.Quit

End Sub

I'm not sure why I had to use the ChangeFileOpenDirectory twice but with only one of them it would open to My Docs every time and then we needed to close the object once done. Again thank you for your help I really appreciate it.
Jan 23 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Yuri Vanzine | last post by:
In asp we can run VBSCRIPT client-side which allows for 'easy' :?) ms office COM object instantiation. How do I access a Word object in ASP.NET on the client side? I would like to do spell...
3
by: Yohancef Chin | last post by:
Hi, Being fairly new to .NET I am looking for a way to call MS Word from an event on a webform, and after the user is finished save that created document to an SQL Server database. Has anyone...
25
by: yanivoliver | last post by:
Hey, I'm using the CommonDialog object to load a dialog which allows the user to select the files they want to upload. This solution works perfectly on computers that have some Visual Studio...
1
by: nsvmani | last post by:
Hi, i am trying to get the FileOpen dialogue window as soon as clicked href link I am using IE6 with ActiveX enabled. Just need to get the File Open dialogue window when i click on the HREF links.It...
5
by: Jamielowmp | last post by:
Hi there... this is my first message in this community. I know there's a lot of benefits in VB macro but i'm not very good at programming (still a basic learner). I have an urgent task that requires...
2
by: ahynes | last post by:
HI folks, I'm a chem engineer with no VB programming knowledge (as you'll see from my question!) I want a script to open a .txt file, insert pre-defined text into the start and end of the...
2
by: ahynes | last post by:
HI folks, I need a script to open a .txt file, insert pre-defined text into the start and end of the file, then close teh saved file with a .nc extension. I'd like to have this so I can run it...
1
by: David C | last post by:
I have an ASP.Net page that displays documents as hyperlinks from a network folder (intranet application). I also have a column that contains a hyperlink to open the document in Microsoft Word. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.